@perevorot/shop 3.0.6 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),r=require("vuex"),t=require("formvuelate"),a=require("vue-toastification"),o=require("@formvuelate/plugin-vee-validate"),n=require("@perevorot/shop/dist/api"),i=require("@perevorot/shop/dist/helpers");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=l(o);function s(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var a,o,n=[],i=!0,l=!1;try{for(t=t.call(e);!(i=(a=t.next()).done)&&(n.push(a.value),!r||n.length!==r);i=!0);}catch(e){l=!0,o=e}finally{try{i||null==t.return||t.return()}finally{if(l)throw o}}return n}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return c(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}var m={name:"user",components:{SchemaForm:t.SchemaFormFactory([u.default({})])},props:{mode:{type:String,default:"registration"}},setup:function(o){var l=r.useStore(),u=e.ref(!1),c=e.ref(!0),m=e.ref({}),d=e.ref({}),f=e.ref({}),v=e.ref({}),p=a.useToast(),h=e.ref(0);t.useSchemaForm(v);return n.auth.registerForm().then((function(e){var r=i.formParse(e.data);"confirm"==o.mode&&(r.schema.email.hidden=!0,r.schema.password.hidden=!0),d.value=r.schema,v.value=Object.assign({},r.model,e.data.model),f.value=r.validation})).finally((function(){c.value=!1})),{loading:u,loadingForm:c,errors:m,schema:d,validation:f,onSubmit:function(){u.value=!0,l.dispatch("auth/update",{credentials:v.value,finally:function(){u.value=!1},callback:function(){p(__("auth."+o.mode+".form.saved"),{type:"success"}),l.commit("auth/modal",null),l.dispatch("auth/me")},catch:function(e){if(e.response&&e.response.data&&e.response.data.errors)for(var r=0,t=Object.entries(e.response.data.errors);r<t.length;r++){var a=s(t[r],2),o=a[0],n=a[1];n[0]&&(m.value[o]=n[0])}else console.error(e);h.value++}})},model:v,key:h}}},d={class:"field"},f={class:"columns is-vcentered"},v={class:"column"};m.render=function(r,t,a,o,n,i){var l=e.resolveComponent("SchemaForm");return o.loadingForm?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(o.model.user_type?"is-user-type-"+o.model.user_type.replaceAll("_","-"):null)},[(e.openBlock(),e.createBlock(l,{schemaRowClasses:"field",schema:o.schema,"validation-schema":o.validation,"initial-errors":o.errors,key:o.key,onSubmit:o.onSubmit},{afterForm:e.withCtx((function(){return[e.createElementVNode("div",d,[e.createElementVNode("div",f,[e.createElementVNode("div",v,[e.createElementVNode("button",{class:e.normalizeClass(["button is-link",{"is-loading":o.loading}]),type:"submit"},e.toDisplayString(r.__("auth."+a.mode+".form.save")),3)])])])]})),_:1},8,["schema","validation-schema","initial-errors","onSubmit"]))],2))},module.exports=m;
1
+ "use strict";var e=require("vue"),r=require("vuex"),t=require("formvuelate"),o=require("vue-toastification"),a=require("@formvuelate/plugin-vee-validate"),n=require("@perevorot/shop/dist/api"),i=require("@perevorot/shop/dist/helpers");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=l(a);function s(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var o,a,n=[],i=!0,l=!1;try{for(t=t.call(e);!(i=(o=t.next()).done)&&(n.push(o.value),!r||n.length!==r);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==t.return||t.return()}finally{if(l)throw a}}return n}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return c(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=new Array(r);t<r;t++)o[t]=e[t];return o}var m={name:"user",components:{SchemaForm:t.SchemaFormFactory([u.default({})])},props:{mode:{type:String,default:"registration"}},setup:function(a){var l=r.useStore(),u=e.ref(!1),c=e.ref(!0),m=e.ref({}),d=e.ref({}),f=e.ref({}),v=e.ref({}),p=o.useToast(),h=e.ref(0);t.useSchemaForm(v);return n.auth.registerForm("confirm"==a.mode?"confirm":null).then((function(e){var r=i.formParse(e.data);d.value=r.schema,v.value=Object.assign({},r.model,e.data.model),f.value=r.validation})).finally((function(){c.value=!1})),{loading:u,loadingForm:c,errors:m,schema:d,validation:f,onSubmit:function(){u.value=!0,l.dispatch("auth/update",{credentials:Object.assign({},v.value,{mode:a.mode}),finally:function(){u.value=!1},callback:function(){p(__("auth."+a.mode+".form.saved"),{type:"success"}),l.commit("auth/modal",null),l.dispatch("auth/me")},catch:function(e){if(e.response&&e.response.data&&e.response.data.errors)for(var r=0,t=Object.entries(e.response.data.errors);r<t.length;r++){var o=s(t[r],2),a=o[0],n=o[1];n[0]&&(m.value[a]=n[0])}else console.error(e);h.value++}})},model:v,key:h}}},d={class:"field"},f={class:"columns is-vcentered"},v={class:"column"};m.render=function(r,t,o,a,n,i){var l=e.resolveComponent("SchemaForm");return a.loadingForm?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(a.model.user_type?"is-user-type-"+a.model.user_type.replaceAll("_","-"):null)},[(e.openBlock(),e.createBlock(l,{schemaRowClasses:"field",schema:a.schema,"validation-schema":a.validation,"initial-errors":a.errors,key:a.key,onSubmit:a.onSubmit},{afterForm:e.withCtx((function(){return[e.createElementVNode("div",d,[e.createElementVNode("div",f,[e.createElementVNode("div",v,[e.createElementVNode("button",{class:e.normalizeClass(["button is-link",{"is-loading":a.loading}]),type:"submit"},e.toDisplayString(r.__("auth."+o.mode+".form.save")),3)])])])]})),_:1},8,["schema","validation-schema","initial-errors","onSubmit"]))],2))},module.exports=m;
2
2
  //# sourceMappingURL=User.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"User.js","sources":["../../../src/components/account/User.vue","../../../src/components/account/User.vue?vue&type=template&id=4578454c&lang.js"],"sourcesContent":["<template>\n <div v-if=\"!loadingForm\" v-bind:class=\"model.user_type ? 'is-user-type-' + model.user_type.replaceAll('_', '-') : null\">\n <SchemaForm schemaRowClasses=\"field\" :schema=\"schema\" :validation-schema=\"validation\" :initial-errors=\"errors\" :key=\"key\" @submit=\"onSubmit\">\n <template #afterForm>\n <div class=\"field\">\n <div class=\"columns is-vcentered\">\n <div class=\"column\">\n <button class=\"button is-link\" type=\"submit\" v-bind:class=\"{ 'is-loading': loading }\">\n {{ __('auth.' + mode + '.form.save') }}\n </button>\n </div>\n </div>\n </div>\n </template>\n </SchemaForm>\n </div>\n</template>\n<script>\nimport { ref } from 'vue';\nimport { useStore } from 'vuex';\nimport { SchemaFormFactory, useSchemaForm } from 'formvuelate';\nimport { useToast } from \"vue-toastification\";\n\nimport VeeValidatePlugin from '@formvuelate/plugin-vee-validate';\nimport { auth as api } from '@perevorot/shop/dist/api';\nimport { formParse } from '@perevorot/shop/dist/helpers';\n\nconst SchemaForm = SchemaFormFactory([VeeValidatePlugin({})]);\n\nexport default {\n name: 'user',\n components: {\n SchemaForm\n },\n props: {\n mode: {\n type: String,\n default: 'registration'\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const loadingForm = ref(true);\n const errors = ref({});\n const schema = ref({});\n const validation = ref({});\n const model = ref({});\n const toast = useToast();\n const key = ref(0);\n\n useSchemaForm(model);\n\n const onSubmit = () => {\n loading.value = true;\n\n store.dispatch('auth/update', {\n credentials: model.value,\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n toast(__('auth.' + props.mode + '.form.saved'), {\n type: 'success'\n });\n\n store.commit('auth/modal', null);\n store.dispatch('auth/me');\n },\n catch: (error) => {\n if (error.response && error.response.data && error.response.data.errors) {\n for (const [field, messages] of Object.entries(error.response.data.errors)) {\n if (messages[0]) {\n errors.value[field] = messages[0];\n }\n }\n } else {\n console.error(error);\n }\n\n key.value++;\n }\n });\n };\n\n api.registerForm()\n .then((response) => {\n const form = formParse(response.data);\n\n if (props.mode == 'confirm') {\n form.schema.email.hidden = true\n form.schema.password.hidden = true;\n }\n\n schema.value = form.schema;\n model.value = { ...form.model, ...response.data.model };\n validation.value = form.validation;\n })\n .finally(() => {\n loadingForm.value = false;\n });\n\n return {\n loading,\n loadingForm,\n errors,\n schema,\n validation,\n onSubmit,\n model,\n key\n };\n }\n};\n</script>","<template>\n <div v-if=\"!loadingForm\" v-bind:class=\"model.user_type ? 'is-user-type-' + model.user_type.replaceAll('_', '-') : null\">\n <SchemaForm schemaRowClasses=\"field\" :schema=\"schema\" :validation-schema=\"validation\" :initial-errors=\"errors\" :key=\"key\" @submit=\"onSubmit\">\n <template #afterForm>\n <div class=\"field\">\n <div class=\"columns is-vcentered\">\n <div class=\"column\">\n <button class=\"button is-link\" type=\"submit\" v-bind:class=\"{ 'is-loading': loading }\">\n {{ __('auth.' + mode + '.form.save') }}\n </button>\n </div>\n </div>\n </div>\n </template>\n </SchemaForm>\n </div>\n</template>\n<script>\nimport { ref } from 'vue';\nimport { useStore } from 'vuex';\nimport { SchemaFormFactory, useSchemaForm } from 'formvuelate';\nimport { useToast } from \"vue-toastification\";\n\nimport VeeValidatePlugin from '@formvuelate/plugin-vee-validate';\nimport { auth as api } from '@perevorot/shop/dist/api';\nimport { formParse } from '@perevorot/shop/dist/helpers';\n\nconst SchemaForm = SchemaFormFactory([VeeValidatePlugin({})]);\n\nexport default {\n name: 'user',\n components: {\n SchemaForm\n },\n props: {\n mode: {\n type: String,\n default: 'registration'\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const loadingForm = ref(true);\n const errors = ref({});\n const schema = ref({});\n const validation = ref({});\n const model = ref({});\n const toast = useToast();\n const key = ref(0);\n\n useSchemaForm(model);\n\n const onSubmit = () => {\n loading.value = true;\n\n store.dispatch('auth/update', {\n credentials: model.value,\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n toast(__('auth.' + props.mode + '.form.saved'), {\n type: 'success'\n });\n\n store.commit('auth/modal', null);\n store.dispatch('auth/me');\n },\n catch: (error) => {\n if (error.response && error.response.data && error.response.data.errors) {\n for (const [field, messages] of Object.entries(error.response.data.errors)) {\n if (messages[0]) {\n errors.value[field] = messages[0];\n }\n }\n } else {\n console.error(error);\n }\n\n key.value++;\n }\n });\n };\n\n api.registerForm()\n .then((response) => {\n const form = formParse(response.data);\n\n if (props.mode == 'confirm') {\n form.schema.email.hidden = true\n form.schema.password.hidden = true;\n }\n\n schema.value = form.schema;\n model.value = { ...form.model, ...response.data.model };\n validation.value = form.validation;\n })\n .finally(() => {\n loadingForm.value = false;\n });\n\n return {\n loading,\n loadingForm,\n errors,\n schema,\n validation,\n onSubmit,\n model,\n key\n };\n }\n};\n</script>"],"names":["name","components","SchemaForm","SchemaFormFactory","VeeValidatePlugin","props","mode","type","String","setup","store","useStore","loading","ref","loadingForm","errors","schema","validation","model","toast","useToast","key","useSchemaForm","api","registerForm","then","response","form","formParse","data","email","hidden","password","value","onSubmit","dispatch","credentials","callback","__","commit","error","Object","entries","field","messages","console","$setup","_createElementBlock","user_type","replaceAll","_createBlock","schemaRowClasses","afterForm","_createElementVNode","_hoisted_1","_hoisted_2","_hoisted_3","_ctx","$props"],"mappings":"8wCA2BA,MAEe,CACXA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0BAA8BF,QAAME,UAAUC,2CACvFC,iBAAYC,iBAAiB,QAASnC,OAAQ8B,6BAA4BA,8BAA6BA,SAASzB,IAAKyB,MAAMZ,SAAQY,aACpHM,qBACP,kBAAAC,2BAAAC,GACID,2BAAAE,GACIF,2BAAAG,GACIH,uDAAc,+BAA6DP,aAA5CvC,KAAK,4BAC7BkD,aAAaC"}
1
+ {"version":3,"file":"User.js","sources":["../../../src/components/account/User.vue","../../../src/components/account/User.vue?vue&type=template&id=2df0e216&lang.js"],"sourcesContent":["<template>\n <div v-if=\"!loadingForm\" v-bind:class=\"model.user_type ? 'is-user-type-' + model.user_type.replaceAll('_', '-') : null\">\n <SchemaForm schemaRowClasses=\"field\" :schema=\"schema\" :validation-schema=\"validation\" :initial-errors=\"errors\" :key=\"key\" @submit=\"onSubmit\">\n <template #afterForm>\n <div class=\"field\">\n <div class=\"columns is-vcentered\">\n <div class=\"column\">\n <button class=\"button is-link\" type=\"submit\" v-bind:class=\"{ 'is-loading': loading }\">\n {{ __('auth.' + mode + '.form.save') }}\n </button>\n </div>\n </div>\n </div>\n </template>\n </SchemaForm>\n </div>\n</template>\n<script>\nimport { ref } from 'vue';\nimport { useStore } from 'vuex';\nimport { SchemaFormFactory, useSchemaForm } from 'formvuelate';\nimport { useToast } from \"vue-toastification\";\n\nimport VeeValidatePlugin from '@formvuelate/plugin-vee-validate';\nimport { auth as api } from '@perevorot/shop/dist/api';\nimport { formParse } from '@perevorot/shop/dist/helpers';\n\nconst SchemaForm = SchemaFormFactory([VeeValidatePlugin({})]);\n\nexport default {\n name: 'user',\n components: {\n SchemaForm\n },\n props: {\n mode: {\n type: String,\n default: 'registration'\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const loadingForm = ref(true);\n const errors = ref({});\n const schema = ref({});\n const validation = ref({});\n const model = ref({});\n const toast = useToast();\n const key = ref(0);\n\n useSchemaForm(model);\n\n const onSubmit = () => {\n loading.value = true;\n\n store.dispatch('auth/update', {\n credentials: { ...model.value, mode: props.mode },\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n toast(__('auth.' + props.mode + '.form.saved'), {\n type: 'success'\n });\n\n store.commit('auth/modal', null);\n store.dispatch('auth/me');\n },\n catch: (error) => {\n if (error.response && error.response.data && error.response.data.errors) {\n for (const [field, messages] of Object.entries(error.response.data.errors)) {\n if (messages[0]) {\n errors.value[field] = messages[0];\n }\n }\n } else {\n console.error(error);\n }\n\n key.value++;\n }\n });\n };\n\n api.registerForm(props.mode == 'confirm' ? 'confirm' : null)\n .then((response) => {\n const form = formParse(response.data);\n\n schema.value = form.schema;\n model.value = { ...form.model, ...response.data.model };\n validation.value = form.validation;\n })\n .finally(() => {\n loadingForm.value = false;\n });\n\n return {\n loading,\n loadingForm,\n errors,\n schema,\n validation,\n onSubmit,\n model,\n key\n };\n }\n};\n</script>","<template>\n <div v-if=\"!loadingForm\" v-bind:class=\"model.user_type ? 'is-user-type-' + model.user_type.replaceAll('_', '-') : null\">\n <SchemaForm schemaRowClasses=\"field\" :schema=\"schema\" :validation-schema=\"validation\" :initial-errors=\"errors\" :key=\"key\" @submit=\"onSubmit\">\n <template #afterForm>\n <div class=\"field\">\n <div class=\"columns is-vcentered\">\n <div class=\"column\">\n <button class=\"button is-link\" type=\"submit\" v-bind:class=\"{ 'is-loading': loading }\">\n {{ __('auth.' + mode + '.form.save') }}\n </button>\n </div>\n </div>\n </div>\n </template>\n </SchemaForm>\n </div>\n</template>\n<script>\nimport { ref } from 'vue';\nimport { useStore } from 'vuex';\nimport { SchemaFormFactory, useSchemaForm } from 'formvuelate';\nimport { useToast } from \"vue-toastification\";\n\nimport VeeValidatePlugin from '@formvuelate/plugin-vee-validate';\nimport { auth as api } from '@perevorot/shop/dist/api';\nimport { formParse } from '@perevorot/shop/dist/helpers';\n\nconst SchemaForm = SchemaFormFactory([VeeValidatePlugin({})]);\n\nexport default {\n name: 'user',\n components: {\n SchemaForm\n },\n props: {\n mode: {\n type: String,\n default: 'registration'\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const loadingForm = ref(true);\n const errors = ref({});\n const schema = ref({});\n const validation = ref({});\n const model = ref({});\n const toast = useToast();\n const key = ref(0);\n\n useSchemaForm(model);\n\n const onSubmit = () => {\n loading.value = true;\n\n store.dispatch('auth/update', {\n credentials: { ...model.value, mode: props.mode },\n finally: () => {\n loading.value = false;\n },\n callback: () => {\n toast(__('auth.' + props.mode + '.form.saved'), {\n type: 'success'\n });\n\n store.commit('auth/modal', null);\n store.dispatch('auth/me');\n },\n catch: (error) => {\n if (error.response && error.response.data && error.response.data.errors) {\n for (const [field, messages] of Object.entries(error.response.data.errors)) {\n if (messages[0]) {\n errors.value[field] = messages[0];\n }\n }\n } else {\n console.error(error);\n }\n\n key.value++;\n }\n });\n };\n\n api.registerForm(props.mode == 'confirm' ? 'confirm' : null)\n .then((response) => {\n const form = formParse(response.data);\n\n schema.value = form.schema;\n model.value = { ...form.model, ...response.data.model };\n validation.value = form.validation;\n })\n .finally(() => {\n loadingForm.value = false;\n });\n\n return {\n loading,\n loadingForm,\n errors,\n schema,\n validation,\n onSubmit,\n model,\n key\n };\n }\n};\n</script>"],"names":["name","components","SchemaForm","SchemaFormFactory","VeeValidatePlugin","props","mode","type","String","setup","store","useStore","loading","ref","loadingForm","errors","schema","validation","model","toast","useToast","key","useSchemaForm","api","registerForm","then","response","form","formParse","data","value","onSubmit","dispatch","credentials","callback","__","commit","error","Object","entries","field","messages","console","$setup","_createElementBlock","user_type","replaceAll","_createBlock","schemaRowClasses","afterForm","_createElementVNode","_hoisted_1","_hoisted_2","_hoisted_3","_ctx","$props"],"mappings":"8wCA2BA,MAEe,CACXA,KAAM,OACNC,WAAY,CACRC,WALWC,oBAAkB,CAACC,UAAkB,OAOpDC,MAAO,CACHC,KAAM,CACFC,KAAMC,eACG,iBAGjBC,eAAMJ,OACIK,EAAQC,aACRC,EAAUC,OAAI,GACdC,EAAcD,OAAI,GAClBE,EAASF,MAAI,IACbG,EAASH,MAAI,I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2 +1,2 @@
1
- "use strict";var e=require("vue");function t(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var o=e.defineComponent({props:{data:Object,item:Object,commit:Function},setup:function(o){var n,r,a=e.computed({get:function(){return o.data[o.item.code]?o.data[o.item.code].city:null},set:function(e){var t={city:e};o.commit(o.item.code,t,i(t))}}),u=e.computed({get:function(){return o.data[o.item.code]?o.data[o.item.code].warehouse:null},set:function(e){var t={city:a.value,warehouse:e};o.commit(o.item.code,t,i(t))}}),l=e.ref(null),i=function(e){return!(!e.city||!e.warehouse)},c=e.inject("shippingComponentValid"),s=e.inject("shippingComponentUserData"),d=e.ref(!1),p=e.ref(!1),v=e.ref(""),y=e.ref(""),h=e.ref([]),m=e.ref([]),f=e.ref([]),w=e.ref(null),k=e.ref(null),g=e.ref(!1),V=e.ref(!1),C=e.ref(!1),E=e.ref(!1),I=e.computed((function(){return!!a.value||!N.value})),N=e.ref(!1),Q=e.computed((function(){return!!u.value||!_.value})),_=e.ref(!1);e.onMounted((function(){var e;o.item.data&&o.item.data.length&&(m.value=o.item.data),c.value=(e=function(){var e=!1;return N.value=!0,_.value=!0,function(e,t){var o=e();return o&&o.then?o.then(t):t(o)}((function(){var t,n,r,i;if(null!==(t=o.item.params)&&void 0!==t&&t.is_other_recipient&&l.value)return n=l.value.isValid(),r=function(t){t&&(s.value=l.value.getValue());var o=!!(a.value&&u.value&&t);return e=!0,o},i?r?r(n):n:(n&&n.then||(n=Promise.resolve(n)),r?n.then(r):n)}),(function(t){return e?t:!(!a.value||!u.value)}))},function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}})}));var B=function(){d.value=!1,p.value=!1,C.value=!1,E.value=!1,N.value=!0,_.value=!0};window.addEventListener("keyup",(function(e){(d.value||p.value)&&"Escape"===e.key&&B()})),window.addEventListener("click",(function(e){!d.value&&!p.value||e.target.closest(".dropdown")||B()})),e.watch(v,(function(e){clearTimeout(r),a.value=null,e&&(g.value=!0,r=setTimeout((function(){$http.post($ziggy("api.delivery-ukr-poshta"),{q:e,action:"cities"}).then((function(e){h.value=e.data.cities})).finally((function(){g.value=!1}))}),400))})),e.watch(y,(function(e){clearTimeout(r),e?(V.value=!0,r=setTimeout((function(){$http.post($ziggy("api.delivery-ukr-poshta"),{q:e,city:a.value.id,action:"warehouses"}).then((function(e){f.value=e.data.warehouses})).finally((function(){V.value=!1}))}),400)):(u.value=null,f.value=[])}));return t(n={isCityOpened:d,isWarehouseOpened:p,openCity:function(){d.value=!0},openWarehouse:function(){p.value=!0},cities:h,citiesPopular:m,warehouses:f,chooseCity:function(e,t){e.stopPropagation(),a.value=t,f.value=[],y.value="",C.value=!1,$http.post($ziggy("api.delivery-ukr-poshta"),{city:t.id,action:"warehouses"}).then((function(e){f.value=e.data.warehouses})).finally((function(){V.value=!1})),B()},chooseWarehouse:function(e,t){e.stopPropagation(),u.value=t,E.value=!1,u.value=t,B()},queryCity:v,queryWarehouse:y,city:a,warehouse:u,loadingCity:g,loadingWarehouse:V,focusWarehouse:function(){_.value=!1,d.value=!1,C.value=!1,E.value||(E.value=!0,e.nextTick((function(){k.value.value=" ",k.value.focus()})))},focusCity:function(){N.value=!1,_.value=!1,p.value=!1,E.value=!1,C.value||(C.value=!0,e.nextTick((function(){w.value.value=" ",w.value.focus()})))}},"city",a),t(n,"warehouse",u),t(n,"cityQueryInput",w),t(n,"warehouseQueryInput",k),t(n,"cityQueryInputInQueryMode",C),t(n,"warehouseQueryInputInQueryMode",E),t(n,"userForm",l),t(n,"cityIsValid",I),t(n,"warehouseIsValid",Q),n}}),n={class:"component ukrposhta-wrapper"},r={class:"user-form"},a=["placeholder"],u=["value"],l=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#arrow-down"})],-1),i={key:0,class:"help is-danger"},c={class:"dropdown-menu"},s={class:"dropdown-content"},d=["onClick"],p={key:0,class:"dropdown-item"},v={class:"user-form"},y=["placeholder"],h=["value"],m=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#arrow-down"})],-1),f={key:0,class:"help is-danger"},w={class:"dropdown-menu"},k={class:"dropdown-content"},g=["onClick"],V={key:0,class:"dropdown-item"},C={class:"dropdown-trigger"},E={class:"user-form"},I={class:"control"},N=e.createElementVNode("input",{type:"text",class:"input",disabled:""},null,-1),Q={class:"label"};o.render=function(t,o,_,B,W,D){var M,b=e.resolveComponent("checkout-shipping-other-recipient");return e.openBlock(),e.createElementBlock("div",n,[null!==(M=t.item.params)&&void 0!==M&&M.is_other_recipient?(e.openBlock(),e.createBlock(b,{key:0,ref:"userForm"},null,512)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",{class:e.normalizeClass(["dropdown",{"is-active":t.isCityOpened,"is-top":t.cityQueryInputInQueryMode}]),onMouseleave:o[4]||(o[4]=function(){return t.close&&t.close.apply(t,arguments)})},[e.createElementVNode("div",{class:"dropdown-trigger",onClick:o[3]||(o[3]=function(){return t.openCity&&t.openCity.apply(t,arguments)})},[e.createElementVNode("div",r,[e.createElementVNode("div",{class:e.normalizeClass(["control",{"is-loading":t.loadingCity,"is-danger":!t.cityIsValid}])},[e.withDirectives(e.createElementVNode("input",{type:"text",class:"input is-nolabel","onUpdate:modelValue":o[0]||(o[0]=function(e){return t.queryCity=e}),onFocus:o[1]||(o[1]=function(){return t.focusCity&&t.focusCity.apply(t,arguments)}),placeholder:t.__("shop.order.city_placeholder"),autocomplete:"chrome-off",ref:"cityQueryInput"},null,40,a),[[e.vModelText,t.queryCity],[e.vShow,t.cityQueryInputInQueryMode]]),e.withDirectives(e.createElementVNode("input",{type:"text",class:"input",value:t.city?t.city.name:"",onFocus:o[2]||(o[2]=function(){return t.focusCity&&t.focusCity.apply(t,arguments)}),placeholder:" "},null,40,u),[[e.vShow,!t.cityQueryInputInQueryMode]]),e.withDirectives(e.createElementVNode("label",{class:"label"},e.toDisplayString(t.__("shop.order.city")),513),[[e.vShow,!t.cityQueryInputInQueryMode]]),l],2),t.cityIsValid?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("p",i,e.toDisplayString(t.__("auth.validation.required")),1))])]),e.createElementVNode("div",c,[e.createElementVNode("div",s,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.queryCity?t.cities:t.citiesPopular,(function(o){return e.openBlock(),e.createElementBlock("a",{class:"dropdown-item",key:o.id,onClick:function(e){return t.chooseCity(e,o)}},e.toDisplayString(o.name),9,d)})),128)),!t.queryCity||t.cities.length||t.loadingCity?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",p,e.toDisplayString(t.__("shop.checkout.shipment.warehouse.not_found")),1))])])],34),t.city?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["dropdown",{"is-active":t.isWarehouseOpened,"is-top":t.warehouseQueryInputInQueryMode}]),onMouseleave:o[9]||(o[9]=function(){return t.close&&t.close.apply(t,arguments)})},[e.createElementVNode("div",{class:"dropdown-trigger",onClick:o[8]||(o[8]=function(){return t.openWarehouse&&t.openWarehouse.apply(t,arguments)})},[e.createElementVNode("div",v,[e.createElementVNode("div",{class:e.normalizeClass(["control",{"is-loading":t.loadingWarehouse,"is-danger":!t.warehouseIsValid}])},[e.withDirectives(e.createElementVNode("input",{type:"text",class:"input is-nolabel","onUpdate:modelValue":o[5]||(o[5]=function(e){return t.queryWarehouse=e}),onFocus:o[6]||(o[6]=function(){return t.focusWarehouse&&t.focusWarehouse.apply(t,arguments)}),placeholder:t.__("shop.order.warehouse_placeholder"),autocomplete:"chrome-off",ref:"warehouseQueryInput"},null,40,y),[[e.vModelText,t.queryWarehouse],[e.vShow,t.warehouseQueryInputInQueryMode]]),e.withDirectives(e.createElementVNode("input",{type:"text",class:"input",value:t.warehouse?t.warehouse.name:"",onFocus:o[7]||(o[7]=function(){return t.focusWarehouse&&t.focusWarehouse.apply(t,arguments)}),placeholder:" "},null,40,h),[[e.vShow,!t.warehouseQueryInputInQueryMode]]),e.withDirectives(e.createElementVNode("label",{class:"label"},e.toDisplayString(t.__("shop.order.warehouse")),513),[[e.vShow,!t.warehouseQueryInputInQueryMode]]),m],2),t.warehouseIsValid?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("p",f,e.toDisplayString(t.__("auth.validation.required")),1))])]),e.createElementVNode("div",w,[e.createElementVNode("div",k,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.warehouses,(function(o){return e.openBlock(),e.createElementBlock("a",{class:"dropdown-item",key:o.id,onClick:function(e){return t.chooseWarehouse(e,o)}},e.toDisplayString(o.name),9,g)})),128)),!t.queryWarehouse||t.warehouses.length||t.loadingWarehouse?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",V,e.toDisplayString(t.__("shop.checkout.shipment.warehouse.not_found")),1))])])],34)):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["dropdown",{"is-top":t.warehouseQueryInputInQueryMode}])},[e.createElementVNode("div",C,[e.createElementVNode("div",E,[e.createElementVNode("div",I,[N,e.createElementVNode("label",Q,e.toDisplayString(t.__("shop.order.warehouse")),1)])])])],2))])},module.exports=o;
1
+ "use strict";var e=require("vue");function t(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}var o=e.defineComponent({props:{data:Object,item:Object,commit:Function,takeUserData:Boolean},setup:function(o){var n,a,r=e.computed({get:function(){return o.data[o.item.code]?o.data[o.item.code].city:N.value},set:function(e){var t={city:e};return o.commit(o.item.code,t,i(t)),e}}),u=e.computed({get:function(){return o.data[o.item.code]?o.data[o.item.code].warehouse:I.value},set:function(e){var t={city:r.value,warehouse:e};return o.commit(o.item.code,t,i(t)),e}}),l=e.ref(null),i=function(e){return!(!e.city||!e.warehouse)},c=e.inject("shippingComponentValid"),s=e.inject("shippingComponentUserData"),d=e.ref(!1),p=e.ref(!1),v=e.ref(""),y=e.ref(""),h=e.ref([]),m=e.ref([]),f=e.ref([]),w=e.ref(null),g=e.ref(null),k=e.ref(!1),V=e.ref(!1),C=e.ref(!1),E=e.ref(!1),N=e.ref(null),I=e.ref(null),_=e.computed((function(){return!!r.value||!Q.value})),Q=e.ref(!1),B=e.computed((function(){return!!u.value||!S.value})),S=e.ref(!1);e.onMounted((function(){if(o.item.data&&o.item.data.length&&(m.value=o.item.data),o.takeUserData){var t,n=e.inject("loggedUser");(null===(t=n.value.shipping_data)||void 0===t?void 0:t.delivery)===o.item.code&&setTimeout((function(){var e,t;N.value=JSON.parse(JSON.stringify(null===(e=n.value.shipping_data)||void 0===e?void 0:e.city)),I.value=JSON.parse(JSON.stringify(null===(t=n.value.shipping_data)||void 0===t?void 0:t.warehouse))}),300)}var a;c.value=(a=function(){var e=!1;return Q.value=!0,S.value=!0,function(e,t){var o=e();return o&&o.then?o.then(t):t(o)}((function(){var t,n,a,i;if(null!==(t=o.item.params)&&void 0!==t&&t.is_other_recipient&&l.value)return n=l.value.isValid(),a=function(t){t&&(s.value=l.value.getValue());var o=!!(r.value&&u.value&&t);return e=!0,o},i?a?a(n):n:(n&&n.then||(n=Promise.resolve(n)),a?n.then(a):n)}),(function(t){return e?t:!(!r.value||!u.value)}))},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(a.apply(this,e))}catch(e){return Promise.reject(e)}})}));var W=function(){d.value=!1,p.value=!1,C.value=!1,E.value=!1,Q.value=!0,S.value=!0};window.addEventListener("keyup",(function(e){(d.value||p.value)&&"Escape"===e.key&&W()})),window.addEventListener("click",(function(e){!d.value&&!p.value||e.target.closest(".dropdown")||W()})),e.watch(v,(function(e){clearTimeout(a),r.value=null,e&&(k.value=!0,a=setTimeout((function(){$http.post($ziggy("api.delivery-ukr-poshta"),{q:e,action:"cities"}).then((function(e){h.value=e.data.cities})).finally((function(){k.value=!1}))}),400))})),e.watch(y,(function(e){clearTimeout(a),e?(V.value=!0,a=setTimeout((function(){$http.post($ziggy("api.delivery-ukr-poshta"),{q:e,city:r.value.id,action:"warehouses"}).then((function(e){f.value=e.data.warehouses})).finally((function(){V.value=!1}))}),400)):(u.value=null,f.value=[])}));return t(n={isCityOpened:d,isWarehouseOpened:p,openCity:function(){d.value=!0},openWarehouse:function(){p.value=!0},cities:h,citiesPopular:m,warehouses:f,chooseCity:function(e,t){e.stopPropagation(),r.value=t,f.value=[],y.value="",C.value=!1,$http.post($ziggy("api.delivery-ukr-poshta"),{city:t.id,action:"warehouses"}).then((function(e){f.value=e.data.warehouses})).finally((function(){V.value=!1})),W()},chooseWarehouse:function(e,t){e.stopPropagation(),u.value=t,E.value=!1,u.value=t,W()},queryCity:v,queryWarehouse:y,city:r,warehouse:u,loadingCity:k,loadingWarehouse:V,focusWarehouse:function(){S.value=!1,d.value=!1,C.value=!1,E.value||(E.value=!0,e.nextTick((function(){g.value.value=" ",g.value.focus()})))},focusCity:function(){Q.value=!1,S.value=!1,p.value=!1,E.value=!1,C.value||(C.value=!0,e.nextTick((function(){w.value.value=" ",w.value.focus()})))}},"city",r),t(n,"warehouse",u),t(n,"cityQueryInput",w),t(n,"warehouseQueryInput",g),t(n,"cityQueryInputInQueryMode",C),t(n,"warehouseQueryInputInQueryMode",E),t(n,"userForm",l),t(n,"cityIsValid",_),t(n,"warehouseIsValid",B),n}}),n={class:"component ukrposhta-wrapper"},a={class:"user-form"},r=["placeholder"],u=["value"],l=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#arrow-down"})],-1),i={key:0,class:"help is-danger"},c={class:"dropdown-menu"},s={class:"dropdown-content"},d=["onClick"],p={key:0,class:"dropdown-item"},v={class:"user-form"},y=["placeholder"],h=["value"],m=e.createElementVNode("svg",null,[e.createElementVNode("use",{"xlink:href":"#arrow-down"})],-1),f={key:0,class:"help is-danger"},w={class:"dropdown-menu"},g={class:"dropdown-content"},k=["onClick"],V={key:0,class:"dropdown-item"},C={class:"dropdown-trigger"},E={class:"user-form"},N={class:"control"},I=e.createElementVNode("input",{type:"text",class:"input",disabled:""},null,-1),_={class:"label"};o.render=function(t,o,Q,B,S,W){var D,M=e.resolveComponent("checkout-shipping-other-recipient");return e.openBlock(),e.createElementBlock("div",n,[null!==(D=t.item.params)&&void 0!==D&&D.is_other_recipient?(e.openBlock(),e.createBlock(M,{key:0,ref:"userForm"},null,512)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",{class:e.normalizeClass(["dropdown",{"is-active":t.isCityOpened,"is-top":t.cityQueryInputInQueryMode}]),onMouseleave:o[4]||(o[4]=function(){return t.close&&t.close.apply(t,arguments)})},[e.createElementVNode("div",{class:"dropdown-trigger",onClick:o[3]||(o[3]=function(){return t.openCity&&t.openCity.apply(t,arguments)})},[e.createElementVNode("div",a,[e.createElementVNode("div",{class:e.normalizeClass(["control",{"is-loading":t.loadingCity,"is-danger":!t.cityIsValid}])},[e.withDirectives(e.createElementVNode("input",{type:"text",class:"input is-nolabel","onUpdate:modelValue":o[0]||(o[0]=function(e){return t.queryCity=e}),onFocus:o[1]||(o[1]=function(){return t.focusCity&&t.focusCity.apply(t,arguments)}),placeholder:t.__("shop.order.city_placeholder"),autocomplete:"chrome-off",ref:"cityQueryInput"},null,40,r),[[e.vModelText,t.queryCity],[e.vShow,t.cityQueryInputInQueryMode]]),e.withDirectives(e.createElementVNode("input",{type:"text",class:"input",value:t.city?t.city.name:"",onFocus:o[2]||(o[2]=function(){return t.focusCity&&t.focusCity.apply(t,arguments)}),placeholder:" "},null,40,u),[[e.vShow,!t.cityQueryInputInQueryMode]]),e.withDirectives(e.createElementVNode("label",{class:"label"},e.toDisplayString(t.__("shop.order.city")),513),[[e.vShow,!t.cityQueryInputInQueryMode]]),l],2),t.cityIsValid?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("p",i,e.toDisplayString(t.__("auth.validation.required")),1))])]),e.createElementVNode("div",c,[e.createElementVNode("div",s,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.queryCity?t.cities:t.citiesPopular,(function(o){return e.openBlock(),e.createElementBlock("a",{class:"dropdown-item",key:o.id,onClick:function(e){return t.chooseCity(e,o)}},e.toDisplayString(o.name),9,d)})),128)),!t.queryCity||t.cities.length||t.loadingCity?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",p,e.toDisplayString(t.__("shop.checkout.shipment.warehouse.not_found")),1))])])],34),t.city?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["dropdown",{"is-active":t.isWarehouseOpened,"is-top":t.warehouseQueryInputInQueryMode}]),onMouseleave:o[9]||(o[9]=function(){return t.close&&t.close.apply(t,arguments)})},[e.createElementVNode("div",{class:"dropdown-trigger",onClick:o[8]||(o[8]=function(){return t.openWarehouse&&t.openWarehouse.apply(t,arguments)})},[e.createElementVNode("div",v,[e.createElementVNode("div",{class:e.normalizeClass(["control",{"is-loading":t.loadingWarehouse,"is-danger":!t.warehouseIsValid}])},[e.withDirectives(e.createElementVNode("input",{type:"text",class:"input is-nolabel","onUpdate:modelValue":o[5]||(o[5]=function(e){return t.queryWarehouse=e}),onFocus:o[6]||(o[6]=function(){return t.focusWarehouse&&t.focusWarehouse.apply(t,arguments)}),placeholder:t.__("shop.order.warehouse_placeholder"),autocomplete:"chrome-off",ref:"warehouseQueryInput"},null,40,y),[[e.vModelText,t.queryWarehouse],[e.vShow,t.warehouseQueryInputInQueryMode]]),e.withDirectives(e.createElementVNode("input",{type:"text",class:"input",value:t.warehouse?t.warehouse.name:"",onFocus:o[7]||(o[7]=function(){return t.focusWarehouse&&t.focusWarehouse.apply(t,arguments)}),placeholder:" "},null,40,h),[[e.vShow,!t.warehouseQueryInputInQueryMode]]),e.withDirectives(e.createElementVNode("label",{class:"label"},e.toDisplayString(t.__("shop.order.warehouse")),513),[[e.vShow,!t.warehouseQueryInputInQueryMode]]),m],2),t.warehouseIsValid?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("p",f,e.toDisplayString(t.__("auth.validation.required")),1))])]),e.createElementVNode("div",w,[e.createElementVNode("div",g,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.warehouses,(function(o){return e.openBlock(),e.createElementBlock("a",{class:"dropdown-item",key:o.id,onClick:function(e){return t.chooseWarehouse(e,o)}},e.toDisplayString(o.name),9,k)})),128)),!t.queryWarehouse||t.warehouses.length||t.loadingWarehouse?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",V,e.toDisplayString(t.__("shop.checkout.shipment.warehouse.not_found")),1))])])],34)):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(["dropdown",{"is-top":t.warehouseQueryInputInQueryMode}])},[e.createElementVNode("div",C,[e.createElementVNode("div",E,[e.createElementVNode("div",N,[I,e.createElementVNode("label",_,e.toDisplayString(t.__("shop.order.warehouse")),1)])])])],2))])},module.exports=o;
2
2
  //# sourceMappingURL=CheckoutShippingUkrposhtaWarehouse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutShippingUkrposhtaWarehouse.js","sources":["../../../../../src/components/shop/order/shipping/CheckoutShippingUkrposhtaWarehouse.vue","../../../../../src/components/shop/order/shipping/CheckoutShippingUkrposhtaWarehouse.vue?vue&type=template&id=defe37f0&lang.js"],"sourcesContent":["<template>\n <div class=\"component ukrposhta-wrapper\">\n <checkout-shipping-other-recipient v-if=\"item.params?.is_other_recipient\" ref=\"userForm\"></checkout-shipping-other-recipient>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-active': isCityOpened, 'is-top': cityQueryInputInQueryMode }\" @mouseleave=\"close\">\n <div class=\"dropdown-trigger\" @click=\"openCity\">\n <div class=\"user-form\">\n <div class=\"control\" v-bind:class=\"{ 'is-loading': loadingCity, 'is-danger': !cityIsValid }\">\n <input type=\"text\" class=\"input is-nolabel\" v-model=\"queryCity\" @focus=\"focusCity\" :placeholder=\"__('shop.order.city_placeholder')\" autocomplete=\"chrome-off\" v-show=\"cityQueryInputInQueryMode\" ref=\"cityQueryInput\" />\n <input type=\"text\" class=\"input\" :value=\"city ? city.name : ''\" @focus=\"focusCity\" placeholder=\" \" v-show=\"!cityQueryInputInQueryMode\" />\n <label class=\"label\" v-show=\"!cityQueryInputInQueryMode\">{{ __('shop.order.city') }}</label>\n <svg>\n <use xlink:href=\"#arrow-down\"></use>\n </svg>\n </div>\n <p class=\"help is-danger\" v-if=\"!cityIsValid\">{{ __('auth.validation.required') }}</p>\n </div>\n </div>\n <div class=\"dropdown-menu\">\n <div class=\"dropdown-content\">\n <a class=\"dropdown-item\" v-for=\"item in queryCity ? cities : citiesPopular\" v-bind:key=\"item.id\" @click=\"chooseCity($event, item)\">{{ item.name }}</a>\n <div class=\"dropdown-item\" v-if=\"queryCity && !cities.length && !loadingCity\">{{ __('shop.checkout.shipment.warehouse.not_found') }}</div>\n </div>\n </div>\n </div>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-active': isWarehouseOpened, 'is-top': warehouseQueryInputInQueryMode }\" v-if=\"city\" @mouseleave=\"close\">\n <div class=\"dropdown-trigger\" @click=\"openWarehouse\">\n <div class=\"user-form\">\n <div class=\"control\" v-bind:class=\"{ 'is-loading': loadingWarehouse, 'is-danger': !warehouseIsValid }\">\n <input type=\"text\" class=\"input is-nolabel\" v-model=\"queryWarehouse\" @focus=\"focusWarehouse\" :placeholder=\"__('shop.order.warehouse_placeholder')\" autocomplete=\"chrome-off\" v-show=\"warehouseQueryInputInQueryMode\" ref=\"warehouseQueryInput\" />\n <input type=\"text\" class=\"input\" :value=\"warehouse ? warehouse.name : ''\" @focus=\"focusWarehouse\" placeholder=\" \" v-show=\"!warehouseQueryInputInQueryMode\" />\n <label class=\"label\" v-show=\"!warehouseQueryInputInQueryMode\">{{ __('shop.order.warehouse') }}</label>\n <svg>\n <use xlink:href=\"#arrow-down\"></use>\n </svg>\n </div>\n <p class=\"help is-danger\" v-if=\"!warehouseIsValid\">{{ __('auth.validation.required') }}</p>\n </div>\n </div>\n <div class=\"dropdown-menu\">\n <div class=\"dropdown-content\">\n <a class=\"dropdown-item\" v-for=\"item in warehouses\" v-bind:key=\"item.id\" @click=\"chooseWarehouse($event, item)\">{{ item.name }}</a>\n <div class=\"dropdown-item\" v-if=\"queryWarehouse && !warehouses.length && !loadingWarehouse\">{{ __('shop.checkout.shipment.warehouse.not_found') }}</div>\n </div>\n </div>\n </div>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-top': warehouseQueryInputInQueryMode }\" v-else>\n <div class=\"dropdown-trigger\">\n <div class=\"user-form\">\n <div class=\"control\">\n <input type=\"text\" class=\"input\" disabled />\n <label class=\"label\">{{ __('shop.order.warehouse') }}</label>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, watch, onMounted, defineComponent, nextTick, inject } from 'vue';\n\nexport default defineComponent({\n props: {\n data: Object,\n item: Object,\n commit: Function\n },\n setup(props) {\n const city = computed({\n get() {\n return props.data[props.item.code] ? props.data[props.item.code].city : null;\n },\n set(city) {\n const data = {\n city: city\n };\n\n props.commit(props.item.code, data, isValid(data));\n }\n });\n\n const warehouse = computed({\n get() {\n return props.data[props.item.code] ? props.data[props.item.code].warehouse : null;\n },\n set(warehouse) {\n const data = {\n city: city.value,\n warehouse: warehouse\n };\n\n props.commit(props.item.code, data, isValid(data));\n }\n });\n\n const userForm = ref(null);\n\n const isValid = (data) => {\n return !!(data.city && data.warehouse);\n };\n\n const shippingComponentValid = inject('shippingComponentValid');\n const shippingComponentUserData = inject('shippingComponentUserData');\n\n const isCityOpened = ref(false);\n const isWarehouseOpened = ref(false);\n const queryCity = ref('');\n const queryWarehouse = ref('');\n const cities = ref([]);\n const citiesPopular = ref([]);\n const warehouses = ref([]);\n const cityQueryInput = ref(null);\n const warehouseQueryInput = ref(null);\n const loadingCity = ref(false);\n const loadingWarehouse = ref(false);\n const cityQueryInputInQueryMode = ref(false);\n const warehouseQueryInputInQueryMode = ref(false);\n\n const cityIsValid = computed(() => {\n return city.value ? true : (!isCityInputBlured.value ? true : false);\n });\n\n const isCityInputBlured = ref(false);\n\n const warehouseIsValid = computed(() => {\n return warehouse.value ? true : (!isWarehouseInputBlured.value ? true : false);\n });\n\n const isWarehouseInputBlured = ref(false);\n\n let typeTimeout;\n\n onMounted(() => {\n if (props.item.data && props.item.data.length) {\n citiesPopular.value = props.item.data;\n }\n\n shippingComponentValid.value = async () => {\n isCityInputBlured.value = true;\n isWarehouseInputBlured.value = true;\n\n if (props.item.params?.is_other_recipient && userForm.value) {\n const valid = await userForm.value.isValid();\n\n if (valid) {\n shippingComponentUserData.value = userForm.value.getValue();\n }\n\n return !!(city.value && warehouse.value && valid);\n }\n\n return !!(city.value && warehouse.value);\n };\n });\n\n const openCity = () => {\n isCityOpened.value = true;\n };\n\n const openWarehouse = () => {\n isWarehouseOpened.value = true;\n };\n\n const close = () => {\n isCityOpened.value = false;\n isWarehouseOpened.value = false;\n\n cityQueryInputInQueryMode.value = false;\n warehouseQueryInputInQueryMode.value = false;\n\n isCityInputBlured.value = true;\n isWarehouseInputBlured.value = true;\n };\n\n const chooseCity = (e, item) => {\n e.stopPropagation();\n\n city.value = item;\n //warehouse.value = null;\n warehouses.value = [];\n queryWarehouse.value = '';\n\n cityQueryInputInQueryMode.value = false;\n\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n city: item.id,\n action: 'warehouses'\n })\n .then((response) => {\n warehouses.value = response.data.warehouses;\n })\n .finally(() => {\n loadingWarehouse.value = false;\n });\n\n close();\n };\n\n const chooseWarehouse = (e, item) => {\n e.stopPropagation();\n\n warehouse.value = item;\n warehouseQueryInputInQueryMode.value = false;\n warehouse.value = item;\n\n close();\n };\n\n window.addEventListener('keyup', (e) => {\n if ((isCityOpened.value || isWarehouseOpened.value) && e.key === 'Escape') {\n close();\n }\n });\n\n window.addEventListener('click', (e) => {\n if ((isCityOpened.value || isWarehouseOpened.value) && !e.target.closest('.dropdown')) {\n close();\n }\n });\n\n watch(queryCity, (q) => {\n clearTimeout(typeTimeout);\n city.value = null;\n\n if (q) {\n loadingCity.value = true;\n\n typeTimeout = setTimeout(() => {\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n q: q,\n action: 'cities'\n })\n .then((response) => {\n cities.value = response.data.cities;\n })\n .finally(() => {\n loadingCity.value = false;\n });\n }, 400);\n }\n });\n\n watch(queryWarehouse, (q) => {\n clearTimeout(typeTimeout);\n\n if (q) {\n loadingWarehouse.value = true;\n\n typeTimeout = setTimeout(() => {\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n q: q,\n city: city.value.id,\n action: 'warehouses'\n })\n .then((response) => {\n warehouses.value = response.data.warehouses;\n })\n .finally(() => {\n loadingWarehouse.value = false;\n });\n }, 400);\n } else {\n warehouse.value = null;\n warehouses.value = [];\n }\n });\n\n const focusWarehouse = () => {\n isWarehouseInputBlured.value = false;\n isCityOpened.value = false;\n cityQueryInputInQueryMode.value = false;\n\n if (!warehouseQueryInputInQueryMode.value) {\n warehouseQueryInputInQueryMode.value = true;\n\n nextTick(() => {\n warehouseQueryInput.value.value = ' ';\n warehouseQueryInput.value.focus();\n });\n }\n };\n\n const focusCity = () => {\n isCityInputBlured.value = false;\n isWarehouseInputBlured.value = false;\n isWarehouseOpened.value = false;\n warehouseQueryInputInQueryMode.value = false;\n\n if (!cityQueryInputInQueryMode.value) {\n cityQueryInputInQueryMode.value = true;\n\n nextTick(() => {\n cityQueryInput.value.value = ' ';\n cityQueryInput.value.focus();\n });\n }\n };\n\n return {\n isCityOpened,\n isWarehouseOpened,\n openCity,\n openWarehouse,\n cities,\n citiesPopular,\n warehouses,\n chooseCity,\n chooseWarehouse,\n queryCity,\n queryWarehouse,\n city,\n warehouse,\n loadingCity,\n loadingWarehouse,\n focusWarehouse,\n focusCity,\n city,\n warehouse,\n cityQueryInput,\n warehouseQueryInput,\n cityQueryInputInQueryMode,\n warehouseQueryInputInQueryMode,\n userForm,\n cityIsValid,\n warehouseIsValid\n };\n }\n});\n</script>\n","<template>\n <div class=\"component ukrposhta-wrapper\">\n <checkout-shipping-other-recipient v-if=\"item.params?.is_other_recipient\" ref=\"userForm\"></checkout-shipping-other-recipient>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-active': isCityOpened, 'is-top': cityQueryInputInQueryMode }\" @mouseleave=\"close\">\n <div class=\"dropdown-trigger\" @click=\"openCity\">\n <div class=\"user-form\">\n <div class=\"control\" v-bind:class=\"{ 'is-loading': loadingCity, 'is-danger': !cityIsValid }\">\n <input type=\"text\" class=\"input is-nolabel\" v-model=\"queryCity\" @focus=\"focusCity\" :placeholder=\"__('shop.order.city_placeholder')\" autocomplete=\"chrome-off\" v-show=\"cityQueryInputInQueryMode\" ref=\"cityQueryInput\" />\n <input type=\"text\" class=\"input\" :value=\"city ? city.name : ''\" @focus=\"focusCity\" placeholder=\" \" v-show=\"!cityQueryInputInQueryMode\" />\n <label class=\"label\" v-show=\"!cityQueryInputInQueryMode\">{{ __('shop.order.city') }}</label>\n <svg>\n <use xlink:href=\"#arrow-down\"></use>\n </svg>\n </div>\n <p class=\"help is-danger\" v-if=\"!cityIsValid\">{{ __('auth.validation.required') }}</p>\n </div>\n </div>\n <div class=\"dropdown-menu\">\n <div class=\"dropdown-content\">\n <a class=\"dropdown-item\" v-for=\"item in queryCity ? cities : citiesPopular\" v-bind:key=\"item.id\" @click=\"chooseCity($event, item)\">{{ item.name }}</a>\n <div class=\"dropdown-item\" v-if=\"queryCity && !cities.length && !loadingCity\">{{ __('shop.checkout.shipment.warehouse.not_found') }}</div>\n </div>\n </div>\n </div>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-active': isWarehouseOpened, 'is-top': warehouseQueryInputInQueryMode }\" v-if=\"city\" @mouseleave=\"close\">\n <div class=\"dropdown-trigger\" @click=\"openWarehouse\">\n <div class=\"user-form\">\n <div class=\"control\" v-bind:class=\"{ 'is-loading': loadingWarehouse, 'is-danger': !warehouseIsValid }\">\n <input type=\"text\" class=\"input is-nolabel\" v-model=\"queryWarehouse\" @focus=\"focusWarehouse\" :placeholder=\"__('shop.order.warehouse_placeholder')\" autocomplete=\"chrome-off\" v-show=\"warehouseQueryInputInQueryMode\" ref=\"warehouseQueryInput\" />\n <input type=\"text\" class=\"input\" :value=\"warehouse ? warehouse.name : ''\" @focus=\"focusWarehouse\" placeholder=\" \" v-show=\"!warehouseQueryInputInQueryMode\" />\n <label class=\"label\" v-show=\"!warehouseQueryInputInQueryMode\">{{ __('shop.order.warehouse') }}</label>\n <svg>\n <use xlink:href=\"#arrow-down\"></use>\n </svg>\n </div>\n <p class=\"help is-danger\" v-if=\"!warehouseIsValid\">{{ __('auth.validation.required') }}</p>\n </div>\n </div>\n <div class=\"dropdown-menu\">\n <div class=\"dropdown-content\">\n <a class=\"dropdown-item\" v-for=\"item in warehouses\" v-bind:key=\"item.id\" @click=\"chooseWarehouse($event, item)\">{{ item.name }}</a>\n <div class=\"dropdown-item\" v-if=\"queryWarehouse && !warehouses.length && !loadingWarehouse\">{{ __('shop.checkout.shipment.warehouse.not_found') }}</div>\n </div>\n </div>\n </div>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-top': warehouseQueryInputInQueryMode }\" v-else>\n <div class=\"dropdown-trigger\">\n <div class=\"user-form\">\n <div class=\"control\">\n <input type=\"text\" class=\"input\" disabled />\n <label class=\"label\">{{ __('shop.order.warehouse') }}</label>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, watch, onMounted, defineComponent, nextTick, inject } from 'vue';\n\nexport default defineComponent({\n props: {\n data: Object,\n item: Object,\n commit: Function\n },\n setup(props) {\n const city = computed({\n get() {\n return props.data[props.item.code] ? props.data[props.item.code].city : null;\n },\n set(city) {\n const data = {\n city: city\n };\n\n props.commit(props.item.code, data, isValid(data));\n }\n });\n\n const warehouse = computed({\n get() {\n return props.data[props.item.code] ? props.data[props.item.code].warehouse : null;\n },\n set(warehouse) {\n const data = {\n city: city.value,\n warehouse: warehouse\n };\n\n props.commit(props.item.code, data, isValid(data));\n }\n });\n\n const userForm = ref(null);\n\n const isValid = (data) => {\n return !!(data.city && data.warehouse);\n };\n\n const shippingComponentValid = inject('shippingComponentValid');\n const shippingComponentUserData = inject('shippingComponentUserData');\n\n const isCityOpened = ref(false);\n const isWarehouseOpened = ref(false);\n const queryCity = ref('');\n const queryWarehouse = ref('');\n const cities = ref([]);\n const citiesPopular = ref([]);\n const warehouses = ref([]);\n const cityQueryInput = ref(null);\n const warehouseQueryInput = ref(null);\n const loadingCity = ref(false);\n const loadingWarehouse = ref(false);\n const cityQueryInputInQueryMode = ref(false);\n const warehouseQueryInputInQueryMode = ref(false);\n\n const cityIsValid = computed(() => {\n return city.value ? true : (!isCityInputBlured.value ? true : false);\n });\n\n const isCityInputBlured = ref(false);\n\n const warehouseIsValid = computed(() => {\n return warehouse.value ? true : (!isWarehouseInputBlured.value ? true : false);\n });\n\n const isWarehouseInputBlured = ref(false);\n\n let typeTimeout;\n\n onMounted(() => {\n if (props.item.data && props.item.data.length) {\n citiesPopular.value = props.item.data;\n }\n\n shippingComponentValid.value = async () => {\n isCityInputBlured.value = true;\n isWarehouseInputBlured.value = true;\n\n if (props.item.params?.is_other_recipient && userForm.value) {\n const valid = await userForm.value.isValid();\n\n if (valid) {\n shippingComponentUserData.value = userForm.value.getValue();\n }\n\n return !!(city.value && warehouse.value && valid);\n }\n\n return !!(city.value && warehouse.value);\n };\n });\n\n const openCity = () => {\n isCityOpened.value = true;\n };\n\n const openWarehouse = () => {\n isWarehouseOpened.value = true;\n };\n\n const close = () => {\n isCityOpened.value = false;\n isWarehouseOpened.value = false;\n\n cityQueryInputInQueryMode.value = false;\n warehouseQueryInputInQueryMode.value = false;\n\n isCityInputBlured.value = true;\n isWarehouseInputBlured.value = true;\n };\n\n const chooseCity = (e, item) => {\n e.stopPropagation();\n\n city.value = item;\n //warehouse.value = null;\n warehouses.value = [];\n queryWarehouse.value = '';\n\n cityQueryInputInQueryMode.value = false;\n\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n city: item.id,\n action: 'warehouses'\n })\n .then((response) => {\n warehouses.value = response.data.warehouses;\n })\n .finally(() => {\n loadingWarehouse.value = false;\n });\n\n close();\n };\n\n const chooseWarehouse = (e, item) => {\n e.stopPropagation();\n\n warehouse.value = item;\n warehouseQueryInputInQueryMode.value = false;\n warehouse.value = item;\n\n close();\n };\n\n window.addEventListener('keyup', (e) => {\n if ((isCityOpened.value || isWarehouseOpened.value) && e.key === 'Escape') {\n close();\n }\n });\n\n window.addEventListener('click', (e) => {\n if ((isCityOpened.value || isWarehouseOpened.value) && !e.target.closest('.dropdown')) {\n close();\n }\n });\n\n watch(queryCity, (q) => {\n clearTimeout(typeTimeout);\n city.value = null;\n\n if (q) {\n loadingCity.value = true;\n\n typeTimeout = setTimeout(() => {\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n q: q,\n action: 'cities'\n })\n .then((response) => {\n cities.value = response.data.cities;\n })\n .finally(() => {\n loadingCity.value = false;\n });\n }, 400);\n }\n });\n\n watch(queryWarehouse, (q) => {\n clearTimeout(typeTimeout);\n\n if (q) {\n loadingWarehouse.value = true;\n\n typeTimeout = setTimeout(() => {\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n q: q,\n city: city.value.id,\n action: 'warehouses'\n })\n .then((response) => {\n warehouses.value = response.data.warehouses;\n })\n .finally(() => {\n loadingWarehouse.value = false;\n });\n }, 400);\n } else {\n warehouse.value = null;\n warehouses.value = [];\n }\n });\n\n const focusWarehouse = () => {\n isWarehouseInputBlured.value = false;\n isCityOpened.value = false;\n cityQueryInputInQueryMode.value = false;\n\n if (!warehouseQueryInputInQueryMode.value) {\n warehouseQueryInputInQueryMode.value = true;\n\n nextTick(() => {\n warehouseQueryInput.value.value = ' ';\n warehouseQueryInput.value.focus();\n });\n }\n };\n\n const focusCity = () => {\n isCityInputBlured.value = false;\n isWarehouseInputBlured.value = false;\n isWarehouseOpened.value = false;\n warehouseQueryInputInQueryMode.value = false;\n\n if (!cityQueryInputInQueryMode.value) {\n cityQueryInputInQueryMode.value = true;\n\n nextTick(() => {\n cityQueryInput.value.value = ' ';\n cityQueryInput.value.focus();\n });\n }\n };\n\n return {\n isCityOpened,\n isWarehouseOpened,\n openCity,\n openWarehouse,\n cities,\n citiesPopular,\n warehouses,\n chooseCity,\n chooseWarehouse,\n queryCity,\n queryWarehouse,\n city,\n warehouse,\n loadingCity,\n loadingWarehouse,\n focusWarehouse,\n focusCity,\n city,\n warehouse,\n cityQueryInput,\n warehouseQueryInput,\n cityQueryInputInQueryMode,\n warehouseQueryInputInQueryMode,\n userForm,\n cityIsValid,\n warehouseIsValid\n };\n }\n});\n</script>\n"],"names":["defineComponent","props","data","Object","item","commit","Function","setup","typeTimeout","city","computed","get","code","set","isValid","warehouse","value","userForm","ref","shippingComponentValid","inject","shippingComponentUserData","isCityOpened","isWarehouseOpened","queryCity","queryWarehouse","cities","citiesPopular","warehouses","cityQueryInput","warehouseQueryInput","loadingCity","loadingWarehouse","cityQueryInputInQueryMode","warehouseQueryInputInQueryMode","cityIsValid","isCityInputBlured","warehouseIsValid","isWarehouseInputBlured","onMounted","f","length","then","direct","params","is_other_recipient","valid","getValue","i","resolve","apply","this","args","close","window","addEventListener","e","key","target","closest","watch","q","clearTimeout","setTimeout","$http","post","$ziggy","action","response","id","openCity","openWarehouse","chooseCity","stopPropagation","chooseWarehouse","focusWarehouse","nextTick","focus","focusCity","_createElementVNode","type","disabled","_createElementBlock","_hoisted_1","_ctx","_ctx$item$params","_createBlock","onMouseleave","onClick","_hoisted_2","onFocus","placeholder","autocomplete","name","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","$event","_hoisted_10","_hoisted_11","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_23","_hoisted_24"],"mappings":"0JA4DA,MAAeA,kBAAgB,CAC3BC,MAAO,CACHC,KAAMC,OACNC,KAAMD,OACNE,OAAQC,UAEZC,eAAMN,SA+DEO,EA9DEC,EAAOC,WAAS,CAClBC,sBACWV,EAAM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OoE,YAAYA,YAAUS,QAAYH,sCAAON,wDAAgBO,YAAY,2BAAaP,qDAC3HL,oCAAa,2BAAoDK,8CAAnCA,oCAC9BiB,MAI6BjB,kEAAjCF,yBAAAoB,oBAAsDlB,0CAG9DL,2BAAAwB,GACIxB,2BAAAyB,oBACItB,kDAAwCE,uBAARhF,wBAAhC8E,gCAAS,gBAAkDzB,IAAKrD,EAAKiE,GAAKmB,2BAAOJ,kBAAgBc,EAAQ9F,uBAAUA,EAAKyF,qBACvFT,kBAAmBA,aAAW3C,QAAW2C,kEAA1EF,2BAAAuB,oBAA+FrB,iFAI3GF,0DAAW,qBAAqCE,sCAC5CL,2BAAA2B,GACI3B,2BAAA4B,GACI5B,2BAAA6B,GACIC,EACA9B,6BAAA+B,oBAAwB1B"}
1
+ {"version":3,"file":"CheckoutShippingUkrposhtaWarehouse.js","sources":["../../../../../src/components/shop/order/shipping/CheckoutShippingUkrposhtaWarehouse.vue","../../../../../src/components/shop/order/shipping/CheckoutShippingUkrposhtaWarehouse.vue?vue&type=template&id=783b4587&lang.js"],"sourcesContent":["<template>\n <div class=\"component ukrposhta-wrapper\">\n <checkout-shipping-other-recipient v-if=\"item.params?.is_other_recipient\" ref=\"userForm\"></checkout-shipping-other-recipient>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-active': isCityOpened, 'is-top': cityQueryInputInQueryMode }\" @mouseleave=\"close\">\n <div class=\"dropdown-trigger\" @click=\"openCity\">\n <div class=\"user-form\">\n <div class=\"control\" v-bind:class=\"{ 'is-loading': loadingCity, 'is-danger': !cityIsValid }\">\n <input type=\"text\" class=\"input is-nolabel\" v-model=\"queryCity\" @focus=\"focusCity\" :placeholder=\"__('shop.order.city_placeholder')\" autocomplete=\"chrome-off\" v-show=\"cityQueryInputInQueryMode\" ref=\"cityQueryInput\" />\n <input type=\"text\" class=\"input\" :value=\"city ? city.name : ''\" @focus=\"focusCity\" placeholder=\" \" v-show=\"!cityQueryInputInQueryMode\" />\n <label class=\"label\" v-show=\"!cityQueryInputInQueryMode\">{{ __('shop.order.city') }}</label>\n <svg>\n <use xlink:href=\"#arrow-down\"></use>\n </svg>\n </div>\n <p class=\"help is-danger\" v-if=\"!cityIsValid\">{{ __('auth.validation.required') }}</p>\n </div>\n </div>\n <div class=\"dropdown-menu\">\n <div class=\"dropdown-content\">\n <a class=\"dropdown-item\" v-for=\"item in queryCity ? cities : citiesPopular\" v-bind:key=\"item.id\" @click=\"chooseCity($event, item)\">{{ item.name }}</a>\n <div class=\"dropdown-item\" v-if=\"queryCity && !cities.length && !loadingCity\">{{ __('shop.checkout.shipment.warehouse.not_found') }}</div>\n </div>\n </div>\n </div>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-active': isWarehouseOpened, 'is-top': warehouseQueryInputInQueryMode }\" v-if=\"city\" @mouseleave=\"close\">\n <div class=\"dropdown-trigger\" @click=\"openWarehouse\">\n <div class=\"user-form\">\n <div class=\"control\" v-bind:class=\"{ 'is-loading': loadingWarehouse, 'is-danger': !warehouseIsValid }\">\n <input type=\"text\" class=\"input is-nolabel\" v-model=\"queryWarehouse\" @focus=\"focusWarehouse\" :placeholder=\"__('shop.order.warehouse_placeholder')\" autocomplete=\"chrome-off\" v-show=\"warehouseQueryInputInQueryMode\" ref=\"warehouseQueryInput\" />\n <input type=\"text\" class=\"input\" :value=\"warehouse ? warehouse.name : ''\" @focus=\"focusWarehouse\" placeholder=\" \" v-show=\"!warehouseQueryInputInQueryMode\" />\n <label class=\"label\" v-show=\"!warehouseQueryInputInQueryMode\">{{ __('shop.order.warehouse') }}</label>\n <svg>\n <use xlink:href=\"#arrow-down\"></use>\n </svg>\n </div>\n <p class=\"help is-danger\" v-if=\"!warehouseIsValid\">{{ __('auth.validation.required') }}</p>\n </div>\n </div>\n <div class=\"dropdown-menu\">\n <div class=\"dropdown-content\">\n <a class=\"dropdown-item\" v-for=\"item in warehouses\" v-bind:key=\"item.id\" @click=\"chooseWarehouse($event, item)\">{{ item.name }}</a>\n <div class=\"dropdown-item\" v-if=\"queryWarehouse && !warehouses.length && !loadingWarehouse\">{{ __('shop.checkout.shipment.warehouse.not_found') }}</div>\n </div>\n </div>\n </div>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-top': warehouseQueryInputInQueryMode }\" v-else>\n <div class=\"dropdown-trigger\">\n <div class=\"user-form\">\n <div class=\"control\">\n <input type=\"text\" class=\"input\" disabled />\n <label class=\"label\">{{ __('shop.order.warehouse') }}</label>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, watch, onMounted, defineComponent, nextTick, inject } from 'vue';\n\nexport default defineComponent({\n props: {\n data: Object,\n item: Object,\n commit: Function,\n takeUserData: Boolean,\n },\n setup(props) {\n const city = computed({\n get() {\n return props.data[props.item.code] ? props.data[props.item.code].city : userCity.value;\n },\n set(city) {\n const data = {\n city: city\n };\n\n props.commit(props.item.code, data, isValid(data));\n return city;\n }\n });\n\n const warehouse = computed({\n get() {\n return props.data[props.item.code] ? props.data[props.item.code].warehouse : userWarehouse.value;\n },\n set(warehouse) {\n const data = {\n city: city.value,\n warehouse: warehouse\n };\n\n props.commit(props.item.code, data, isValid(data));\n return warehouse;\n }\n });\n\n const userForm = ref(null);\n\n const isValid = (data) => {\n return !!(data.city && data.warehouse);\n };\n\n const shippingComponentValid = inject('shippingComponentValid');\n const shippingComponentUserData = inject('shippingComponentUserData');\n\n const isCityOpened = ref(false);\n const isWarehouseOpened = ref(false);\n const queryCity = ref('');\n const queryWarehouse = ref('');\n const cities = ref([]);\n const citiesPopular = ref([]);\n const warehouses = ref([]);\n const cityQueryInput = ref(null);\n const warehouseQueryInput = ref(null);\n const loadingCity = ref(false);\n const loadingWarehouse = ref(false);\n const cityQueryInputInQueryMode = ref(false);\n const warehouseQueryInputInQueryMode = ref(false);\n const userCity = ref(null);\n const userWarehouse = ref(null);\n\n const cityIsValid = computed(() => {\n return city.value ? true : (!isCityInputBlured.value ? true : false);\n });\n\n const isCityInputBlured = ref(false);\n\n const warehouseIsValid = computed(() => {\n return warehouse.value ? true : (!isWarehouseInputBlured.value ? true : false);\n });\n\n const isWarehouseInputBlured = ref(false);\n\n let typeTimeout;\n\n onMounted(() => {\n if (props.item.data && props.item.data.length) {\n citiesPopular.value = props.item.data;\n }\n\n if (props.takeUserData) {\n const loggedUser = inject('loggedUser');\n const code = loggedUser.value.shipping_data?.delivery;\n\n if (code === props.item.code) {\n setTimeout(() => {\n userCity.value = JSON.parse(JSON.stringify(loggedUser.value.shipping_data?.city));\n userWarehouse.value = JSON.parse(JSON.stringify(loggedUser.value.shipping_data?.warehouse));\n }, 300);\n }\n }\n\n shippingComponentValid.value = async () => {\n isCityInputBlured.value = true;\n isWarehouseInputBlured.value = true;\n\n if (props.item.params?.is_other_recipient && userForm.value) {\n const valid = await userForm.value.isValid();\n\n if (valid) {\n shippingComponentUserData.value = userForm.value.getValue();\n }\n\n return !!(city.value && warehouse.value && valid);\n }\n\n return !!(city.value && warehouse.value);\n };\n });\n\n const openCity = () => {\n isCityOpened.value = true;\n };\n\n const openWarehouse = () => {\n isWarehouseOpened.value = true;\n };\n\n const close = () => {\n isCityOpened.value = false;\n isWarehouseOpened.value = false;\n\n cityQueryInputInQueryMode.value = false;\n warehouseQueryInputInQueryMode.value = false;\n\n isCityInputBlured.value = true;\n isWarehouseInputBlured.value = true;\n };\n\n const chooseCity = (e, item) => {\n e.stopPropagation();\n\n city.value = item;\n //warehouse.value = null;\n warehouses.value = [];\n queryWarehouse.value = '';\n\n cityQueryInputInQueryMode.value = false;\n\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n city: item.id,\n action: 'warehouses'\n })\n .then((response) => {\n warehouses.value = response.data.warehouses;\n })\n .finally(() => {\n loadingWarehouse.value = false;\n });\n\n close();\n };\n\n const chooseWarehouse = (e, item) => {\n e.stopPropagation();\n\n warehouse.value = item;\n warehouseQueryInputInQueryMode.value = false;\n warehouse.value = item;\n\n close();\n };\n\n window.addEventListener('keyup', (e) => {\n if ((isCityOpened.value || isWarehouseOpened.value) && e.key === 'Escape') {\n close();\n }\n });\n\n window.addEventListener('click', (e) => {\n if ((isCityOpened.value || isWarehouseOpened.value) && !e.target.closest('.dropdown')) {\n close();\n }\n });\n\n watch(queryCity, (q) => {\n clearTimeout(typeTimeout);\n city.value = null;\n\n if (q) {\n loadingCity.value = true;\n\n typeTimeout = setTimeout(() => {\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n q: q,\n action: 'cities'\n })\n .then((response) => {\n cities.value = response.data.cities;\n })\n .finally(() => {\n loadingCity.value = false;\n });\n }, 400);\n }\n });\n\n watch(queryWarehouse, (q) => {\n clearTimeout(typeTimeout);\n\n if (q) {\n loadingWarehouse.value = true;\n\n typeTimeout = setTimeout(() => {\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n q: q,\n city: city.value.id,\n action: 'warehouses'\n })\n .then((response) => {\n warehouses.value = response.data.warehouses;\n })\n .finally(() => {\n loadingWarehouse.value = false;\n });\n }, 400);\n } else {\n warehouse.value = null;\n warehouses.value = [];\n }\n });\n\n const focusWarehouse = () => {\n isWarehouseInputBlured.value = false;\n isCityOpened.value = false;\n cityQueryInputInQueryMode.value = false;\n\n if (!warehouseQueryInputInQueryMode.value) {\n warehouseQueryInputInQueryMode.value = true;\n\n nextTick(() => {\n warehouseQueryInput.value.value = ' ';\n warehouseQueryInput.value.focus();\n });\n }\n };\n\n const focusCity = () => {\n isCityInputBlured.value = false;\n isWarehouseInputBlured.value = false;\n isWarehouseOpened.value = false;\n warehouseQueryInputInQueryMode.value = false;\n\n if (!cityQueryInputInQueryMode.value) {\n cityQueryInputInQueryMode.value = true;\n\n nextTick(() => {\n cityQueryInput.value.value = ' ';\n cityQueryInput.value.focus();\n });\n }\n };\n\n return {\n isCityOpened,\n isWarehouseOpened,\n openCity,\n openWarehouse,\n cities,\n citiesPopular,\n warehouses,\n chooseCity,\n chooseWarehouse,\n queryCity,\n queryWarehouse,\n city,\n warehouse,\n loadingCity,\n loadingWarehouse,\n focusWarehouse,\n focusCity,\n city,\n warehouse,\n cityQueryInput,\n warehouseQueryInput,\n cityQueryInputInQueryMode,\n warehouseQueryInputInQueryMode,\n userForm,\n cityIsValid,\n warehouseIsValid\n };\n }\n});\n</script>\n","<template>\n <div class=\"component ukrposhta-wrapper\">\n <checkout-shipping-other-recipient v-if=\"item.params?.is_other_recipient\" ref=\"userForm\"></checkout-shipping-other-recipient>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-active': isCityOpened, 'is-top': cityQueryInputInQueryMode }\" @mouseleave=\"close\">\n <div class=\"dropdown-trigger\" @click=\"openCity\">\n <div class=\"user-form\">\n <div class=\"control\" v-bind:class=\"{ 'is-loading': loadingCity, 'is-danger': !cityIsValid }\">\n <input type=\"text\" class=\"input is-nolabel\" v-model=\"queryCity\" @focus=\"focusCity\" :placeholder=\"__('shop.order.city_placeholder')\" autocomplete=\"chrome-off\" v-show=\"cityQueryInputInQueryMode\" ref=\"cityQueryInput\" />\n <input type=\"text\" class=\"input\" :value=\"city ? city.name : ''\" @focus=\"focusCity\" placeholder=\" \" v-show=\"!cityQueryInputInQueryMode\" />\n <label class=\"label\" v-show=\"!cityQueryInputInQueryMode\">{{ __('shop.order.city') }}</label>\n <svg>\n <use xlink:href=\"#arrow-down\"></use>\n </svg>\n </div>\n <p class=\"help is-danger\" v-if=\"!cityIsValid\">{{ __('auth.validation.required') }}</p>\n </div>\n </div>\n <div class=\"dropdown-menu\">\n <div class=\"dropdown-content\">\n <a class=\"dropdown-item\" v-for=\"item in queryCity ? cities : citiesPopular\" v-bind:key=\"item.id\" @click=\"chooseCity($event, item)\">{{ item.name }}</a>\n <div class=\"dropdown-item\" v-if=\"queryCity && !cities.length && !loadingCity\">{{ __('shop.checkout.shipment.warehouse.not_found') }}</div>\n </div>\n </div>\n </div>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-active': isWarehouseOpened, 'is-top': warehouseQueryInputInQueryMode }\" v-if=\"city\" @mouseleave=\"close\">\n <div class=\"dropdown-trigger\" @click=\"openWarehouse\">\n <div class=\"user-form\">\n <div class=\"control\" v-bind:class=\"{ 'is-loading': loadingWarehouse, 'is-danger': !warehouseIsValid }\">\n <input type=\"text\" class=\"input is-nolabel\" v-model=\"queryWarehouse\" @focus=\"focusWarehouse\" :placeholder=\"__('shop.order.warehouse_placeholder')\" autocomplete=\"chrome-off\" v-show=\"warehouseQueryInputInQueryMode\" ref=\"warehouseQueryInput\" />\n <input type=\"text\" class=\"input\" :value=\"warehouse ? warehouse.name : ''\" @focus=\"focusWarehouse\" placeholder=\" \" v-show=\"!warehouseQueryInputInQueryMode\" />\n <label class=\"label\" v-show=\"!warehouseQueryInputInQueryMode\">{{ __('shop.order.warehouse') }}</label>\n <svg>\n <use xlink:href=\"#arrow-down\"></use>\n </svg>\n </div>\n <p class=\"help is-danger\" v-if=\"!warehouseIsValid\">{{ __('auth.validation.required') }}</p>\n </div>\n </div>\n <div class=\"dropdown-menu\">\n <div class=\"dropdown-content\">\n <a class=\"dropdown-item\" v-for=\"item in warehouses\" v-bind:key=\"item.id\" @click=\"chooseWarehouse($event, item)\">{{ item.name }}</a>\n <div class=\"dropdown-item\" v-if=\"queryWarehouse && !warehouses.length && !loadingWarehouse\">{{ __('shop.checkout.shipment.warehouse.not_found') }}</div>\n </div>\n </div>\n </div>\n <div class=\"dropdown\" v-bind:class=\"{ 'is-top': warehouseQueryInputInQueryMode }\" v-else>\n <div class=\"dropdown-trigger\">\n <div class=\"user-form\">\n <div class=\"control\">\n <input type=\"text\" class=\"input\" disabled />\n <label class=\"label\">{{ __('shop.order.warehouse') }}</label>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed, watch, onMounted, defineComponent, nextTick, inject } from 'vue';\n\nexport default defineComponent({\n props: {\n data: Object,\n item: Object,\n commit: Function,\n takeUserData: Boolean,\n },\n setup(props) {\n const city = computed({\n get() {\n return props.data[props.item.code] ? props.data[props.item.code].city : userCity.value;\n },\n set(city) {\n const data = {\n city: city\n };\n\n props.commit(props.item.code, data, isValid(data));\n return city;\n }\n });\n\n const warehouse = computed({\n get() {\n return props.data[props.item.code] ? props.data[props.item.code].warehouse : userWarehouse.value;\n },\n set(warehouse) {\n const data = {\n city: city.value,\n warehouse: warehouse\n };\n\n props.commit(props.item.code, data, isValid(data));\n return warehouse;\n }\n });\n\n const userForm = ref(null);\n\n const isValid = (data) => {\n return !!(data.city && data.warehouse);\n };\n\n const shippingComponentValid = inject('shippingComponentValid');\n const shippingComponentUserData = inject('shippingComponentUserData');\n\n const isCityOpened = ref(false);\n const isWarehouseOpened = ref(false);\n const queryCity = ref('');\n const queryWarehouse = ref('');\n const cities = ref([]);\n const citiesPopular = ref([]);\n const warehouses = ref([]);\n const cityQueryInput = ref(null);\n const warehouseQueryInput = ref(null);\n const loadingCity = ref(false);\n const loadingWarehouse = ref(false);\n const cityQueryInputInQueryMode = ref(false);\n const warehouseQueryInputInQueryMode = ref(false);\n const userCity = ref(null);\n const userWarehouse = ref(null);\n\n const cityIsValid = computed(() => {\n return city.value ? true : (!isCityInputBlured.value ? true : false);\n });\n\n const isCityInputBlured = ref(false);\n\n const warehouseIsValid = computed(() => {\n return warehouse.value ? true : (!isWarehouseInputBlured.value ? true : false);\n });\n\n const isWarehouseInputBlured = ref(false);\n\n let typeTimeout;\n\n onMounted(() => {\n if (props.item.data && props.item.data.length) {\n citiesPopular.value = props.item.data;\n }\n\n if (props.takeUserData) {\n const loggedUser = inject('loggedUser');\n const code = loggedUser.value.shipping_data?.delivery;\n\n if (code === props.item.code) {\n setTimeout(() => {\n userCity.value = JSON.parse(JSON.stringify(loggedUser.value.shipping_data?.city));\n userWarehouse.value = JSON.parse(JSON.stringify(loggedUser.value.shipping_data?.warehouse));\n }, 300);\n }\n }\n\n shippingComponentValid.value = async () => {\n isCityInputBlured.value = true;\n isWarehouseInputBlured.value = true;\n\n if (props.item.params?.is_other_recipient && userForm.value) {\n const valid = await userForm.value.isValid();\n\n if (valid) {\n shippingComponentUserData.value = userForm.value.getValue();\n }\n\n return !!(city.value && warehouse.value && valid);\n }\n\n return !!(city.value && warehouse.value);\n };\n });\n\n const openCity = () => {\n isCityOpened.value = true;\n };\n\n const openWarehouse = () => {\n isWarehouseOpened.value = true;\n };\n\n const close = () => {\n isCityOpened.value = false;\n isWarehouseOpened.value = false;\n\n cityQueryInputInQueryMode.value = false;\n warehouseQueryInputInQueryMode.value = false;\n\n isCityInputBlured.value = true;\n isWarehouseInputBlured.value = true;\n };\n\n const chooseCity = (e, item) => {\n e.stopPropagation();\n\n city.value = item;\n //warehouse.value = null;\n warehouses.value = [];\n queryWarehouse.value = '';\n\n cityQueryInputInQueryMode.value = false;\n\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n city: item.id,\n action: 'warehouses'\n })\n .then((response) => {\n warehouses.value = response.data.warehouses;\n })\n .finally(() => {\n loadingWarehouse.value = false;\n });\n\n close();\n };\n\n const chooseWarehouse = (e, item) => {\n e.stopPropagation();\n\n warehouse.value = item;\n warehouseQueryInputInQueryMode.value = false;\n warehouse.value = item;\n\n close();\n };\n\n window.addEventListener('keyup', (e) => {\n if ((isCityOpened.value || isWarehouseOpened.value) && e.key === 'Escape') {\n close();\n }\n });\n\n window.addEventListener('click', (e) => {\n if ((isCityOpened.value || isWarehouseOpened.value) && !e.target.closest('.dropdown')) {\n close();\n }\n });\n\n watch(queryCity, (q) => {\n clearTimeout(typeTimeout);\n city.value = null;\n\n if (q) {\n loadingCity.value = true;\n\n typeTimeout = setTimeout(() => {\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n q: q,\n action: 'cities'\n })\n .then((response) => {\n cities.value = response.data.cities;\n })\n .finally(() => {\n loadingCity.value = false;\n });\n }, 400);\n }\n });\n\n watch(queryWarehouse, (q) => {\n clearTimeout(typeTimeout);\n\n if (q) {\n loadingWarehouse.value = true;\n\n typeTimeout = setTimeout(() => {\n $http\n .post($ziggy('api.delivery-ukr-poshta'), {\n q: q,\n city: city.value.id,\n action: 'warehouses'\n })\n .then((response) => {\n warehouses.value = response.data.warehouses;\n })\n .finally(() => {\n loadingWarehouse.value = false;\n });\n }, 400);\n } else {\n warehouse.value = null;\n warehouses.value = [];\n }\n });\n\n const focusWarehouse = () => {\n isWarehouseInputBlured.value = false;\n isCityOpened.value = false;\n cityQueryInputInQueryMode.value = false;\n\n if (!warehouseQueryInputInQueryMode.value) {\n warehouseQueryInputInQueryMode.value = true;\n\n nextTick(() => {\n warehouseQueryInput.value.value = ' ';\n warehouseQueryInput.value.focus();\n });\n }\n };\n\n const focusCity = () => {\n isCityInputBlured.value = false;\n isWarehouseInputBlured.value = false;\n isWarehouseOpened.value = false;\n warehouseQueryInputInQueryMode.value = false;\n\n if (!cityQueryInputInQueryMode.value) {\n cityQueryInputInQueryMode.value = true;\n\n nextTick(() => {\n cityQueryInput.value.value = ' ';\n cityQueryInput.value.focus();\n });\n }\n };\n\n return {\n isCityOpened,\n isWarehouseOpened,\n openCity,\n openWarehouse,\n cities,\n citiesPopular,\n warehouses,\n chooseCity,\n chooseWarehouse,\n queryCity,\n queryWarehouse,\n city,\n warehouse,\n loadingCity,\n loadingWarehouse,\n focusWarehouse,\n focusCity,\n city,\n warehouse,\n cityQueryInput,\n warehouseQueryInput,\n cityQueryInputInQueryMode,\n warehouseQueryInputInQueryMode,\n userForm,\n cityIsValid,\n warehouseIsValid\n };\n }\n});\n</script>\n"],"names":["defineComponent","props","data","Object","item","commit","Function","takeUserData","Boolean","setup","typeTimeout","city","computed","get","code","userCity","value","set","isValid","warehouse","userWarehouse","userForm","ref","shippingComponentValid","inject","shippingComponentUserData","isCityOpened","isWarehouseOpened","queryCity","queryWarehouse","cities","citiesPopular","warehouses","cityQueryInput","warehouseQueryInput","loadingCity","loadingWarehouse","cityQueryInputInQueryMode","warehouseQueryInputInQueryMode","cityIsValid","isCityInputBlured","warehouseIsValid","isWarehouseInputBlured","onMounted","length","loggedUser","shipping_data","_loggedUser$value$shi","delivery","setTimeout","JSON","parse","stringify","_loggedUser$value$shi2","_loggedUser$value$shi3","then","direct","params","is_other_recipient","valid","getValue","i","arguments","e","close","window","addEventListener","key","target","closest","watch","q","clearTimeout","$http","post","$ziggy","action","response","id","openCity","openWarehouse","chooseCity","stopPropagation","chooseWarehouse","focusWarehouse","nextTick","focus","focusCity","_createElementVNode","type","disabled","_createElementBlock","_hoisted_1","_ctx","_ctx$item$params","_createBlock","onMouseleave","onClick","_hoisted_2","onFocus","placeholder","autocomplete","name","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","$event","_hoisted_10","_hoisted_11","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_19","_hoisted_20","_hoisted_21","_hoisted_22","_hoisted_23","_hoisted_24"],"mappings":"0JA4DA,MAAeA,kBAAgB,CAC3BC,MAAO,CACHC,KAAMC,OACNC,KAAMD,OACNE,OAAQC,SACRC,aAAcC,SAElBC,eAAMR,SAmEES,EAlEEC,EAAOC,WAAS,CAClBC,sBACWZ,EAAMC,KAAKD,EAAMG,KAAKU,MAAQb,EAAMC,KAAKD,EAAMG,KAAKU,MAAMH,KAAOI,EAASC,OAErFC,aAAIN,OACMT,EAAO,CACTS,KAAMA,UAGVV,EAAMI,OAAOJ,EAAMG,KAAKU,KAAMZ,EAAMgB,EAAQhB,IACrCS,KAITQ,EAAYP,WAAS,CACvBC,sBACWZ,EAAMC,KAAKD,EAAMG,KAAKU,MAAQb,EAAMC,KAAKD,EAAMG,KAAKU,MAAMK,UAAYC,EAAcJ,OAE/FC,aAAIE,OACMjB,EAAO,CACTS,KAAMA,EAAKK,MACXG,UAAWA,UAGflB,EAAMI,OAAOJ,EAAMG,KAAKU,KAAMZ,EAAMgB,EAAQhB,IACrCiB,KAITE,EAAWC,MAAI,MAEfJ,EAAU,SAAChB,YACHA,EAAKS,OAAQT,EAAKiB,YAG1BI,EAAyBC,SAAO,0BAChCC,EAA4BD,SAAO,6BAEnCE,EAAeJ,OAAI,GACnBK,EAAoBL,OAAI,GACxBM,EAAYN,MAAI,IAChBO,E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