@ikas/storefront 0.2.0-alpha.6 → 0.2.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/{[slug]-03fe2246.js → [slug]-256d483b.js} +1 -1
- package/build/cjs/analytics.js +1 -1
- package/build/cjs/api.js +1 -1
- package/build/cjs/{base-87cf6de7.js → base-3f6c0c18.js} +1 -1
- package/build/cjs/{blog-category-list-c0cacf56.js → blog-category-list-301760cf.js} +1 -1
- package/build/cjs/{cart-f6e4a77c.js → cart-cdd60c45.js} +1 -1
- package/build/cjs/components.js +1 -1
- package/build/cjs/{en-23346d2b.js → en-39787a68.js} +0 -0
- package/build/cjs/{get-d8074995.js → get-9a974b32.js} +0 -0
- package/build/cjs/{i18n-64322bef.js → i18n-c9c8631c.js} +1 -1
- package/build/cjs/{index-0b53d9bd.js → index-0102eb01.js} +1 -1
- package/build/cjs/{index-ee4bdd5a.js → index-0e84ec4c.js} +1 -1
- package/build/cjs/{index-2db7c894.js → index-346e3673.js} +1 -1
- package/build/cjs/{index-9c362bcc.js → index-557eda08.js} +1 -1
- package/build/cjs/{index-b0e04fe3.js → index-60458497.js} +1 -1
- package/build/cjs/{index-e7773270.js → index-6b3fb1e9.js} +1 -1
- package/build/cjs/{index-9b798e08.js → index-bb1c2b0f.js} +1 -1
- package/build/cjs/{index-23f8268d.js → index-c5a4b4b2.js} +1 -1
- package/build/cjs/{index-40ded420.js → index-dfb3bc66.js} +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/models.js +1 -1
- package/build/cjs/pages.js +1 -1
- package/build/cjs/store.js +1 -1
- package/build/cjs/{tr-e96d42a2.js → tr-b58ac020.js} +0 -0
- package/build/cjs/utils.js +1 -1
- package/build/esm/{[slug]-31f18157.js → [slug]-a5af448c.js} +1 -1
- package/build/esm/analytics.js +1 -1
- package/build/esm/api.js +1 -1
- package/build/esm/{base-af09cf31.js → base-64b83211.js} +1 -1
- package/build/esm/{blog-category-list-f6d3e84b.js → blog-category-list-f9bde7de.js} +1 -1
- package/build/esm/{cart-e7ee5904.js → cart-a5410bc1.js} +1 -1
- package/build/esm/components.js +1 -1
- package/build/esm/{en-3c767374.js → en-61fffa63.js} +0 -0
- package/build/esm/{get-41aa8e36.js → get-ade3f4d4.js} +0 -0
- package/build/esm/{i18n-bdaf13ed.js → i18n-faeafc92.js} +1 -1
- package/build/esm/{index-05282f31.js → index-2108fd47.js} +1 -1
- package/build/esm/{index-d59c6c67.js → index-3e13a5d9.js} +1 -1
- package/build/esm/{index-4119675c.js → index-413970db.js} +1 -1
- package/build/esm/{index-c9e27f67.js → index-42f5840b.js} +1 -1
- package/build/esm/{index-271a4063.js → index-4adde2ba.js} +1 -1
- package/build/esm/{index-d26b7878.js → index-63a08778.js} +1 -1
- package/build/esm/index-7a9b2ec6.js +1 -0
- package/build/esm/{index-d2801a81.js → index-9157d480.js} +1 -1
- package/build/esm/{index-cf81c712.js → index-dbaba7ab.js} +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/models.js +1 -1
- package/build/esm/pages.js +1 -1
- package/build/esm/store.js +1 -1
- package/build/esm/{tr-7d1712d7.js → tr-8305fadb.js} +0 -0
- package/build/esm/utils.js +1 -1
- package/package.json +1 -1
- package/build/esm/index-84704340.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as n,c as t,e}from"./get-
|
|
1
|
+
import{_ as n,c as t,e}from"./get-ade3f4d4.js";import{aj as a,i as r,ah as o}from"./index-2108fd47.js";import{IkasStorefrontConfig as d}from"./storefront.js";var i,s,u=function(){function u(){}return u.saveItemToCart=function(d){return n(this,void 0,void 0,(function(){var n,s,u,c,I;return t(this,(function(t){switch(t.label){case 0:n=o(i||(i=e(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "],["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n taxLines {\n price\n rate\n }\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "]))),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.getClient().mutate({mutation:n,variables:{input:d}})];case 2:return s=t.sent(),u=s.data,(c=s.errors)&&c.length&&console.log(c),u?[2,new a(u.saveItemToCart)]:[3,4];case 3:return I=t.sent(),console.log(I),[3,4];case 4:return[2]}}))}))},u.getCart=function(i,u){return n(this,void 0,void 0,(function(){var n,c,I,m,l;return t(this,(function(t){switch(t.label){case 0:n=o(s||(s=e(["\n query getCart(\n $cartId: String\n $customerId: String\n $storefrontRoutingId: String\n ) {\n getCart(\n id: $cartId\n customerId: $customerId\n storefrontRoutingId: $storefrontRoutingId\n ) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "],["\n query getCart(\n $cartId: String\n $customerId: String\n $storefrontRoutingId: String\n ) {\n getCart(\n id: $cartId\n customerId: $customerId\n storefrontRoutingId: $storefrontRoutingId\n ) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "]))),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.getClient().query({query:n,variables:{cartId:i,customerId:u,storefrontRoutingId:d.storefrontRoutingId}})];case 2:return c=t.sent(),I=c.data,(m=c.errors)&&m.length&&console.log(m),I&&I.getCart?[2,new a(I.getCart)]:[3,4];case 3:return l=t.sent(),console.log(l),[3,4];case 4:return[2]}}))}))},u}();export{u as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{useRef as n,useEffect as t,createElement as o,useState as i,Fragment as r}from"react";import{observer as a}from"mobx-react-lite";import{useRouter as s}from"next/router";import{_ as p,c as u,i as d}from"./get-41aa8e36.js";import{makeAutoObservable as c,runInAction as l,computed as m}from"mobx";import{c as h,d as f,e as g,f as v,a as P}from"./index-d2801a81.js";import{ab as E,ad as C,i as O,ac as T,H as _,aj as N,s as D,av as A}from"./index-05282f31.js";import{IkasStorefrontConfig as M}from"./storefront.js";import{c as y,b as I,e as S}from"./index-4119675c.js";function L(n){var t=(void 0===n?{}:n).name;return e.createElement("div",{style:U},"Error! Please fill the component ",t," fields")}var w,U={lineHeight:"50px",textAlign:"center",fontSize:"16px",margin:"10px 0",border:"2px solid rgb(255, 0, 0)",backgroundColor:"rgba(255, 0, 0, 0.5)"},R=function(){function e(e){var n=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.locale="en",this.pageParams={},this.queryParams={},this.apiKey=null,this.pageDataProvider=null,this.startMessaging=function(){window.addEventListener("message",n.onMessage,!1),n.sendMessage(w.FRAME_DID_LOAD,"0.0.163-alpha.13")},this.onMessage=function(e){return p(n,void 0,void 0,(function(){var n,t;return u(this,(function(o){switch(o.label){case 0:switch(n=e.data.type,t=e.data.data,n){case w.UPDATE_FRAME_DATA:return[3,1];case w.UPDATE_PROP_VALUE:return[3,3];case w.UPDATE_PAGE_PARAMS:return[3,5];case w.UPDATE_PAGE_COMPONENT_ORDER:return[3,7];case w.ADD_COMPONENT:return[3,9];case w.DELETE_COMPONENT:return[3,10];case w.UPDATE_COMPONENT:return[3,11];case w.ADD_PAGE_COMPONENT:return[3,12];case w.DELETE_PAGE_COMPONENT:return[3,14];case w.SET_SELECTED_COMPONENT:return[3,15];case w.SET_HOVERED_COMPONENT:return[3,16];case w.SCROLL_TO_COMPONENT:return[3,17];case w.UPDATE_THEME_SETTINGS:return[3,18]}return[3,19];case 1:return[4,this.handleUpdateFrameData(t)];case 2:case 4:case 6:case 8:case 13:return o.sent(),[3,20];case 3:return[4,this.handleUpdatePropValue(t)];case 5:return[4,this.handleUpdatePageParams(t)];case 7:return[4,this.handleUpdatePageComponentOrder(t)];case 9:return this.handleAddNewComponent(t),[3,20];case 10:return this.handleDeleteComponent(t),[3,20];case 11:return this.handleUpdateComponent(t),[3,20];case 12:return[4,this.handleAddNewPageComponent(t)];case 14:return this.handleDeletePageComponent(t),[3,20];case 15:return this.handleSetSelectedComponent(t),[3,20];case 16:return this.handleSetHoveredComponent(t),[3,20];case 17:return this.handleScrollToComponent(t),[3,20];case 18:return this.updateThemeSettings(t),[3,20];case 19:return[3,20];case 20:return[2]}}))}))},this.onClick=function(e){n.sendMessage(w.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){n.sendMessage(w.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){n.sendMessage(w.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.sendMessage=function(e,n){window.parent.postMessage({type:e,data:n},"*")},this.getPagePropValues=function(){return p(n,void 0,void 0,(function(){var e,n,t,o,i=this;return u(this,(function(r){switch(r.label){case 0:return e=new f(this.theme,this.pageParams,null===(n=this.page)||void 0===n?void 0:n.type),((null===(t=this.pageParams)||void 0===t?void 0:t.blogId)||(null===(o=this.pageParams)||void 0===o?void 0:o.blogCategoryId))&&(e.possiblePageTypes=[E.BLOG,E.BLOG_CATEGORY]),this.isLoading=!0,[4,e.getPageData()];case 1:return r.sent(),e.pageSpecificData&&h.setPageSpecificData(JSON.stringify(e.pageSpecificData),this.page.type,!0),e.pageComponentPropValues=h.initPropValues(JSON.stringify(e.pageComponentPropValues),this.router,JSON.stringify(this.theme.settings)),l((function(){i.pageDataProvider=e,i.isLoading=!1})),[2]}}))}))},this.setComponentRef=function(e,t){n.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var n=e.getBoundingClientRect(),t=n.top,o=n.bottom;return t<window.innerHeight&&o>=0&&o<window.innerHeight&&t>0},this.handleUpdateFrameData=function(e){return p(n,void 0,void 0,(function(){var n,t,o,i=this;return u(this,(function(r){switch(r.label){case 0:return this.theme=new I(e.theme),this.page=this.theme.pages.find((function(n){return n.id===e.selectedPage.id})),this.pageParams=e.pageParams,this.queryParams=e.queryParams,this.apiKey=e.apiKey,this.locale=e.locale||"en",this.translations=e.translations||void 0,(n=e.storefront)&&(t=new g(n),o=t.routings.find((function(e){return e.locale===i.locale})),M.storefrontId=t.id,M.storefrontRoutingId=null==o?void 0:o.id,t.mainStorefrontThemeId&&(M.storefrontThemeId=t.mainStorefrontThemeId),t.salesChannelId&&(M.salesChannelId=t.salesChannelId),(null==o?void 0:o.priceListId)&&(M.priceListId=o.priceListId),M.routings=t.routings,M.stockPreference=this.theme.settings.stockPreference),this.translations&&(M.translations=this.translations),M.isEditor=!0,O.createApolloClient(this.apiKey||void 0),window.editorApiKey=e.apiKey,[4,this.getPagePropValues()];case 1:return r.sent(),[2]}}))}))},this.handleUpdatePropValue=function(e){return p(n,void 0,void 0,(function(){var n,t,o,i,r,a,s,p,d=this;return u(this,(function(u){switch(u.label){case 0:return n=e.propName,t=e.value,(o=null===(s=null===(a=this.selectedComponent)||void 0===a?void 0:a.props)||void 0===s?void 0:s.find((function(e){return e.name===n})))&&this.selectedPageComponent?(i=null===(p=this.pageDataProvider)||void 0===p?void 0:p.pageComponentPropValues.find((function(e){return e.pageComponent.id===d.selectedPageComponentId})),this.selectedPageComponent.propValues[n]=t,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,o)]:[2]):[2];case 1:return r=u.sent(),l((function(){i&&(i.propValues[n]=r,o.type===S.CUSTOM?h.initCustomDataPropValue(o,r,i,d.router,d.theme.settings,!0):o.type===S.COMPONENT?h.initComponentPropValue(o,r,i,d.router,d.theme.settings,!0):o.type===S.COMPONENT_LIST&&h.initComponentListPropValue(o,r,i,d.router,d.theme.settings,!0))})),[2]}}))}))},this.handleUpdatePageParams=function(e){return p(n,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return this.pageParams=e.pageParams,this.queryParams=e.queryParams,[4,this.getPagePropValues()];case 1:return n.sent(),[2]}}))}))},this.handleUpdatePageComponentOrder=function(e){return p(n,void 0,void 0,(function(){return u(this,(function(n){return this.specification?this.specification.components=e.pageComponents.map((function(e){return new T(e)})):this.page.components=e.pageComponents.map((function(e){return new T(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,o=new y(e.component);null===(t=n.theme)||void 0===t||t.components.push(o)},this.handleDeleteComponent=function(e){var t,o;(null===(t=n.theme)||void 0===t?void 0:t.components)&&(n.theme.components=n.theme.components.filter((function(n){return n.id!==e.componentId})));var i=n.pageComponents.filter((function(n){return n.componentId!==e.componentId}))||[];n.specification&&n.specification.components&&(n.specification.components=i),!n.specification&&(null===(o=n.page)||void 0===o?void 0:o.components)&&(n.page.components=i)},this.handleUpdateComponent=function(e){var t=n.theme.components.findIndex((function(n){return n.id===e.component.id}));-1!==t&&(n.theme.components[t]=new y(e.component))},this.handleAddNewPageComponent=function(e){return p(n,void 0,void 0,(function(){var n,t,o=this;return u(this,(function(i){switch(i.label){case 0:return n=new T(e.pageComponent),this.pageComponents.some((function(e){return e.id===n.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(n)];case 1:return t=i.sent(),l((function(){t.component.props.filter((function(e){return e.type===S.CUSTOM})).forEach((function(e){h.initCustomDataPropValue(e,t.propValues[e.name],t,o.router,o.theme.settings,!0)})),o.pageDataProvider.pageComponentPropValues.push(t),o.pageComponents.push(n)})),[2]}}))}))},this.handleDeletePageComponent=function(e){n.specification?n.specification.components=n.pageComponents.filter((function(n){return n.id!==e.pageComponentId})):n.page.components=n.pageComponents.filter((function(n){return n.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){n.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){n.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,o=n.componentRefs[t];o&&(n.isScrolledIntoView(o)||window.scrollTo({top:o.offsetTop,behavior:"smooth"}))},this.updateThemeSettings=function(e){var t=e.settings;n.theme&&(n.theme.settings=new C(t))},this.router=e,c(this),this.startMessaging()}return Object.defineProperty(e.prototype,"specification",{get:function(){var e,n,t,o,i,r,a=this,s=this.page;return(null==s?void 0:s.type)===E.PRODUCT&&(r=null===(e=s.specifications)||void 0===e?void 0:e.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.productId)}))),(null==s?void 0:s.type)===E.CATEGORY&&(r=null===(n=s.specifications)||void 0===n?void 0:n.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.categoryId)}))),(null==s?void 0:s.type)===E.BRAND&&(r=null===(t=s.specifications)||void 0===t?void 0:t.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.brandId)}))),(null==s?void 0:s.type)===E.BLOG&&(r=null===(o=s.specifications)||void 0===o?void 0:o.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.blogId)}))),(null==s?void 0:s.type)===E.BLOG_CATEGORY&&(r=null===(i=s.specifications)||void 0===i?void 0:i.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.blogCategoryId)}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(n){return n.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedComponent",{get:function(){var e,n=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var t;return e.id===(null===(t=n.selectedPageComponent)||void 0===t?void 0:t.componentId)}))},enumerable:!1,configurable:!0}),e}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS"}(w||(w={}));var b=a((function(e){var i,r,a,s=e.vm,p=e.pageComponent,u=n(null),c=M.store,l=M.currentPageComponents;t((function(){s.setComponentRef(u.current,p)}),[]),t((function(){var e;null===(e=s.theme)||void 0===e||e.settings.colors.map((function(e){return document.documentElement.style.setProperty(e.key,e.color)}))}),[null===(i=s.theme)||void 0===i?void 0:i.settings]);var f=m((function(){return s.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===p.id}))})),g=null===(r=f.get())||void 0===r?void 0:r.propValues;if(!g)return null;if(!l)return console.error("Components for the page not found."),null;var P=l[p.componentId];if((null===(a=s.page)||void 0===a?void 0:a.type)===E.CHECKOUT){P=v;var C={checkout:new _({cart:new N({items:[new D({currencyCode:"₺",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new A,merchantSettings:null,customizationProps:d({},g),returnPolicy:"",privacyPolicy:"",termsOfService:""};g=C}var O=m((function(){return s.selectedPageComponentId===p.id})),T=m((function(){return s.hoveredPageComponentId===p.id})),y=m((function(){var e;return null===(e=f.get())||void 0===e?void 0:e.component.props.some((function(e){if(e.isRequired){var n=(g||{})[e.name];return null===n||null==n}}))})),I=m((function(){var e;return y.get()?o(L,null):o(P,d({store:c},g,{settings:null===(e=s.theme)||void 0===e?void 0:e.settings,pageSpecificData:h.pageSpecificData}))}));return o("div",{ref:u,style:{position:"relative"},onMouseEnter:function(){s.onMouseOver(p.id)},onMouseLeave:function(){s.onMouseLeave(p.id)},onClick:function(){s.onClick(p.id)}},I.get(),(O.get()||T.get())&&o("div",{style:V}))})),V={position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%",border:"4px solid rgb(0, 161, 255)",zIndex:1e19},G=a((function(){var e,n,t,a=s(),p=i((function(){return new R(a)}))[0];if(p.isLoading)return null;var u=null===(e=p.pageComponents)||void 0===e?void 0:e.find((function(e){var n,t;return e.componentId===(null===(t=null===(n=p.theme)||void 0===n?void 0:n.headerComponent)||void 0===t?void 0:t.id)})),d=null===(n=p.pageComponents)||void 0===n?void 0:n.find((function(e){var n,t;return e.componentId===(null===(t=null===(n=p.theme)||void 0===n?void 0:n.footerComponent)||void 0===t?void 0:t.id)})),c=null===(t=p.pageComponents)||void 0===t?void 0:t.filter((function(e){var n,t,o,i;return e.componentId!==(null===(t=null===(n=p.theme)||void 0===n?void 0:n.headerComponent)||void 0===t?void 0:t.id)&&e.componentId!==(null===(i=null===(o=p.theme)||void 0===o?void 0:o.footerComponent)||void 0===i?void 0:i.id)}));return o(r,null,!!p.page&&o(P,{pageType:p.page.type,pageTitle:p.page.pageTitle,pageDescription:p.page.description}),o("div",{style:x},o("div",null,!!u&&o(b,{key:u.id,vm:p,pageComponent:u}),null==c?void 0:c.map((function(e){return o(b,{key:e.id,vm:p,pageComponent:e})}))),!!d&&o(b,{key:d.id,vm:p,pageComponent:d})))})),x={minHeight:"100vh",width:"100vw",display:"flex",flexDirection:"column",justifyContent:"space-between"};export{G as I};
|
|
1
|
+
import e,{useRef as n,useEffect as t,createElement as o,useState as i,Fragment as r}from"react";import{observer as a}from"mobx-react-lite";import{useRouter as s}from"next/router";import{_ as d,c as p,i as u}from"./get-ade3f4d4.js";import{makeAutoObservable as c,runInAction as l,computed as m}from"mobx";import{c as h,d as f,e as g,f as v,a as P}from"./index-9157d480.js";import{ab as E,ad as C,i as O,ac as T,H as _,aj as N,s as D,av as A}from"./index-2108fd47.js";import{IkasStorefrontConfig as M}from"./storefront.js";import{c as y,b as I,e as S}from"./index-413970db.js";function L(n){var t=(void 0===n?{}:n).name;return e.createElement("div",{style:U},"Error! Please fill the component ",t," fields")}var w,U={lineHeight:"50px",textAlign:"center",fontSize:"16px",margin:"10px 0",border:"2px solid rgb(255, 0, 0)",backgroundColor:"rgba(255, 0, 0, 0.5)"},R=function(){function e(e){var n=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.locale="en",this.pageParams={},this.queryParams={},this.apiKey=null,this.pageDataProvider=null,this.startMessaging=function(){window.addEventListener("message",n.onMessage,!1),n.sendMessage(w.FRAME_DID_LOAD,"0.0.163-alpha.13")},this.onMessage=function(e){return d(n,void 0,void 0,(function(){var n,t;return p(this,(function(o){switch(o.label){case 0:switch(n=e.data.type,t=e.data.data,n){case w.UPDATE_FRAME_DATA:return[3,1];case w.UPDATE_PROP_VALUE:return[3,3];case w.UPDATE_PAGE_PARAMS:return[3,5];case w.UPDATE_PAGE_COMPONENT_ORDER:return[3,7];case w.ADD_COMPONENT:return[3,9];case w.DELETE_COMPONENT:return[3,10];case w.UPDATE_COMPONENT:return[3,11];case w.ADD_PAGE_COMPONENT:return[3,12];case w.DELETE_PAGE_COMPONENT:return[3,14];case w.SET_SELECTED_COMPONENT:return[3,15];case w.SET_HOVERED_COMPONENT:return[3,16];case w.SCROLL_TO_COMPONENT:return[3,17];case w.UPDATE_THEME_SETTINGS:return[3,18]}return[3,19];case 1:return[4,this.handleUpdateFrameData(t)];case 2:case 4:case 6:case 8:case 13:return o.sent(),[3,20];case 3:return[4,this.handleUpdatePropValue(t)];case 5:return[4,this.handleUpdatePageParams(t)];case 7:return[4,this.handleUpdatePageComponentOrder(t)];case 9:return this.handleAddNewComponent(t),[3,20];case 10:return this.handleDeleteComponent(t),[3,20];case 11:return this.handleUpdateComponent(t),[3,20];case 12:return[4,this.handleAddNewPageComponent(t)];case 14:return this.handleDeletePageComponent(t),[3,20];case 15:return this.handleSetSelectedComponent(t),[3,20];case 16:return this.handleSetHoveredComponent(t),[3,20];case 17:return this.handleScrollToComponent(t),[3,20];case 18:return this.updateThemeSettings(t),[3,20];case 19:return[3,20];case 20:return[2]}}))}))},this.onClick=function(e){n.sendMessage(w.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){n.sendMessage(w.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){n.sendMessage(w.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.sendMessage=function(e,n){window.parent.postMessage({type:e,data:n},"*")},this.getPagePropValues=function(){return d(n,void 0,void 0,(function(){var e,n,t,o,i=this;return p(this,(function(r){switch(r.label){case 0:return e=new f(this.theme,this.pageParams,null===(n=this.page)||void 0===n?void 0:n.type),((null===(t=this.pageParams)||void 0===t?void 0:t.blogId)||(null===(o=this.pageParams)||void 0===o?void 0:o.blogCategoryId))&&(e.possiblePageTypes=[E.BLOG,E.BLOG_CATEGORY]),this.isLoading=!0,[4,e.getPageData()];case 1:return r.sent(),e.pageSpecificData&&h.setPageSpecificData(JSON.stringify(e.pageSpecificData),this.page.type,!0),e.pageComponentPropValues=h.initPropValues(JSON.stringify(e.pageComponentPropValues),this.router,JSON.stringify(this.theme.settings)),l((function(){i.pageDataProvider=e,i.isLoading=!1})),[2]}}))}))},this.setComponentRef=function(e,t){n.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var n=e.getBoundingClientRect(),t=n.top,o=n.bottom;return t<window.innerHeight&&o>=0&&o<window.innerHeight&&t>0},this.handleUpdateFrameData=function(e){return d(n,void 0,void 0,(function(){var n,t,o,i=this;return p(this,(function(r){switch(r.label){case 0:return this.theme=new I(e.theme),this.page=this.theme.pages.find((function(n){return n.id===e.selectedPage.id})),this.pageParams=e.pageParams,this.queryParams=e.queryParams,this.apiKey=e.apiKey,this.locale=e.locale||"en",this.translations=e.translations||void 0,(n=e.storefront)&&(t=new g(n),o=t.routings.find((function(e){return e.locale===i.locale})),M.storefrontId=t.id,M.storefrontRoutingId=null==o?void 0:o.id,t.mainStorefrontThemeId&&(M.storefrontThemeId=t.mainStorefrontThemeId),t.salesChannelId&&(M.salesChannelId=t.salesChannelId),(null==o?void 0:o.priceListId)&&(M.priceListId=o.priceListId),M.routings=t.routings,M.stockPreference=this.theme.settings.stockPreference),this.translations&&(M.translations=this.translations),M.isEditor=!0,O.createApolloClient(this.apiKey||void 0),window.editorApiKey=e.apiKey,[4,this.getPagePropValues()];case 1:return r.sent(),[2]}}))}))},this.handleUpdatePropValue=function(e){return d(n,void 0,void 0,(function(){var n,t,o,i,r,a,s,d,u=this;return p(this,(function(p){switch(p.label){case 0:return n=e.propName,t=e.value,(o=null===(s=null===(a=this.selectedComponent)||void 0===a?void 0:a.props)||void 0===s?void 0:s.find((function(e){return e.name===n})))&&this.selectedPageComponent?(i=null===(d=this.pageDataProvider)||void 0===d?void 0:d.pageComponentPropValues.find((function(e){return e.pageComponent.id===u.selectedPageComponentId})),this.selectedPageComponent.propValues[n]=t,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,o)]:[2]):[2];case 1:return r=p.sent(),l((function(){i&&(i.propValues[n]=r,o.type===S.CUSTOM?h.initCustomDataPropValue(o,r,i,u.router,u.theme.settings,!0):o.type===S.COMPONENT?h.initComponentPropValue(o,r,i,u.router,u.theme.settings,!0):o.type===S.COMPONENT_LIST&&h.initComponentListPropValue(o,r,i,u.router,u.theme.settings,!0))})),[2]}}))}))},this.handleUpdatePageParams=function(e){return d(n,void 0,void 0,(function(){return p(this,(function(n){switch(n.label){case 0:return this.pageParams=e.pageParams,this.queryParams=e.queryParams,[4,this.getPagePropValues()];case 1:return n.sent(),[2]}}))}))},this.handleUpdatePageComponentOrder=function(e){return d(n,void 0,void 0,(function(){return p(this,(function(n){return this.specification?this.specification.components=e.pageComponents.map((function(e){return new T(e)})):this.page.components=e.pageComponents.map((function(e){return new T(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,o=new y(e.component);null===(t=n.theme)||void 0===t||t.components.push(o)},this.handleDeleteComponent=function(e){var t,o;(null===(t=n.theme)||void 0===t?void 0:t.components)&&(n.theme.components=n.theme.components.filter((function(n){return n.id!==e.componentId})));var i=n.pageComponents.filter((function(n){return n.componentId!==e.componentId}))||[];n.specification&&n.specification.components&&(n.specification.components=i),!n.specification&&(null===(o=n.page)||void 0===o?void 0:o.components)&&(n.page.components=i)},this.handleUpdateComponent=function(e){var t=n.theme.components.findIndex((function(n){return n.id===e.component.id}));-1!==t&&(n.theme.components[t]=new y(e.component))},this.handleAddNewPageComponent=function(e){return d(n,void 0,void 0,(function(){var n,t,o=this;return p(this,(function(i){switch(i.label){case 0:return n=new T(e.pageComponent),this.pageComponents.some((function(e){return e.id===n.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(n)];case 1:return t=i.sent(),l((function(){t.component.props.filter((function(e){return e.type===S.CUSTOM})).forEach((function(e){h.initCustomDataPropValue(e,t.propValues[e.name],t,o.router,o.theme.settings,!0)})),o.pageDataProvider.pageComponentPropValues.push(t),o.pageComponents.push(n)})),[2]}}))}))},this.handleDeletePageComponent=function(e){n.specification?n.specification.components=n.pageComponents.filter((function(n){return n.id!==e.pageComponentId})):n.page.components=n.pageComponents.filter((function(n){return n.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){n.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){n.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,o=n.componentRefs[t];o&&(n.isScrolledIntoView(o)||window.scrollTo({top:o.offsetTop,behavior:"smooth"}))},this.updateThemeSettings=function(e){var t=e.settings;n.theme&&(n.theme.settings=new C(t))},this.router=e,c(this),this.startMessaging()}return Object.defineProperty(e.prototype,"specification",{get:function(){var e,n,t,o,i,r,a=this,s=this.page;return(null==s?void 0:s.type)===E.PRODUCT&&(r=null===(e=s.specifications)||void 0===e?void 0:e.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.productId)}))),(null==s?void 0:s.type)===E.CATEGORY&&(r=null===(n=s.specifications)||void 0===n?void 0:n.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.categoryId)}))),(null==s?void 0:s.type)===E.BRAND&&(r=null===(t=s.specifications)||void 0===t?void 0:t.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.brandId)}))),(null==s?void 0:s.type)===E.BLOG&&(r=null===(o=s.specifications)||void 0===o?void 0:o.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.blogId)}))),(null==s?void 0:s.type)===E.BLOG_CATEGORY&&(r=null===(i=s.specifications)||void 0===i?void 0:i.find((function(e){var n;return e.id===(null===(n=a.pageParams)||void 0===n?void 0:n.blogCategoryId)}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(n){return n.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedComponent",{get:function(){var e,n=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var t;return e.id===(null===(t=n.selectedPageComponent)||void 0===t?void 0:t.componentId)}))},enumerable:!1,configurable:!0}),e}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS"}(w||(w={}));var b=a((function(e){var i,r,a,s=e.vm,d=e.pageComponent,p=n(null),c=M.store,l=M.currentPageComponents;t((function(){s.setComponentRef(p.current,d)}),[]),t((function(){var e;null===(e=s.theme)||void 0===e||e.settings.colors.map((function(e){return document.documentElement.style.setProperty(e.key,e.color)}))}),[null===(i=s.theme)||void 0===i?void 0:i.settings]);var f=m((function(){return s.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===d.id}))})),g=null===(r=f.get())||void 0===r?void 0:r.propValues;if(!g)return null;if(!l)return console.error("Components for the page not found."),null;var P=l[d.componentId];if((null===(a=s.page)||void 0===a?void 0:a.type)===E.CHECKOUT){P=v;var C={checkout:new _({cart:new N({items:[new D({currencyCode:"₺",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new A,merchantSettings:null,customizationProps:u({},g),returnPolicy:"",privacyPolicy:"",termsOfService:""};g=C}var O=m((function(){return s.selectedPageComponentId===d.id})),T=m((function(){return s.hoveredPageComponentId===d.id})),y=m((function(){var e;return null===(e=f.get())||void 0===e?void 0:e.component.props.some((function(e){if(e.isRequired){var n=(g||{})[e.name];return null===n||null==n}}))})),I=m((function(){var e;return y.get()?o(L,null):o(P,u({store:c},g,{settings:null===(e=s.theme)||void 0===e?void 0:e.settings,pageSpecificData:h.pageSpecificData}))}));return o("div",{ref:p,style:{position:"relative"},onMouseEnter:function(){s.onMouseOver(d.id)},onMouseLeave:function(){s.onMouseLeave(d.id)},onClick:function(){s.onClick(d.id)}},I.get(),(O.get()||T.get())&&o("div",{style:V}))})),V={position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%",border:"4px solid rgb(0, 161, 255)",zIndex:1e19},G=a((function(){var e,n,t,a=s(),d=i((function(){return new R(a)}))[0];if(d.isLoading)return null;var p=null===(e=d.pageComponents)||void 0===e?void 0:e.find((function(e){var n,t;return e.componentId===(null===(t=null===(n=d.theme)||void 0===n?void 0:n.headerComponent)||void 0===t?void 0:t.id)})),u=null===(n=d.pageComponents)||void 0===n?void 0:n.find((function(e){var n,t;return e.componentId===(null===(t=null===(n=d.theme)||void 0===n?void 0:n.footerComponent)||void 0===t?void 0:t.id)})),c=null===(t=d.pageComponents)||void 0===t?void 0:t.filter((function(e){var n,t,o,i;return e.componentId!==(null===(t=null===(n=d.theme)||void 0===n?void 0:n.headerComponent)||void 0===t?void 0:t.id)&&e.componentId!==(null===(i=null===(o=d.theme)||void 0===o?void 0:o.footerComponent)||void 0===i?void 0:i.id)}));return o(r,null,!!d.page&&o(P,{pageType:d.page.type,pageTitle:d.page.pageTitle,pageDescription:d.page.description}),o("div",{style:x},o("div",null,!!p&&o(b,{key:p.id,vm:d,pageComponent:p}),null==c?void 0:c.map((function(e){return o(b,{key:e.id,vm:d,pageComponent:e})}))),!!u&&o(b,{key:u.id,vm:d,pageComponent:u})))})),x={minHeight:"100vh",width:"100vw",display:"flex",flexDirection:"column",justifyContent:"space-between"};export{G as I};
|