@ikas/storefront 0.2.0-alpha.7 → 0.2.0-alpha.9
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]-c3efec75.js → [slug]-e484ad76.js} +1 -1
- package/build/cjs/analytics.js +1 -1
- package/build/cjs/api.js +1 -1
- package/build/cjs/{base-6b93f997.js → base-1fa38f9a.js} +1 -1
- package/build/cjs/blog-category-list-2bc016a2.js +1 -0
- package/build/cjs/{cart-8b6a2951.js → cart-90632b65.js} +1 -1
- package/build/cjs/components.js +1 -1
- package/build/cjs/{en-e3cbabf6.js → en-a1fa5309.js} +0 -0
- package/build/cjs/{get-7400a559.js → get-e74270ba.js} +0 -0
- package/build/cjs/{i18n-0303b446.js → i18n-23489f2d.js} +1 -1
- package/build/cjs/{index-7343404a.js → index-4896761a.js} +1 -1
- package/build/cjs/{index-c75f4868.js → index-5114bb73.js} +1 -1
- package/build/cjs/{index-2bed1aff.js → index-681c2517.js} +1 -1
- package/build/cjs/{index-d04fee37.js → index-9a0c47b1.js} +1 -1
- package/build/cjs/{index-45530bb2.js → index-a851ebb1.js} +1 -1
- package/build/cjs/{index-84548617.js → index-a8b07648.js} +1 -1
- package/build/cjs/{index-30376afa.js → index-ad398c13.js} +1 -1
- package/build/cjs/{index-af30c815.js → index-b8b2616a.js} +1 -1
- package/build/cjs/{index-5b6bd214.js → index-eceaf256.js} +1 -1
- package/build/cjs/index.js +1 -1
- package/build/cjs/models.js +1 -1
- package/build/cjs/pages/[slug]/index.d.ts +0 -3
- package/build/cjs/pages/[slug]/providers.d.ts +3 -0
- package/build/cjs/pages/index.d.ts +2 -1
- package/build/cjs/pages.js +1 -1
- package/build/cjs/store.js +1 -1
- package/build/cjs/{tr-c4424931.js → tr-5b03d013.js} +0 -0
- package/build/cjs/utils.js +1 -1
- package/build/esm/{[slug]-5be05d9d.js → [slug]-a90edd15.js} +1 -1
- package/build/esm/analytics.js +1 -1
- package/build/esm/api.js +1 -1
- package/build/esm/{base-5ced4c24.js → base-46969f69.js} +1 -1
- package/build/esm/{blog-category-list-00ac6ea3.js → blog-category-list-8bbfffa4.js} +1 -1
- package/build/esm/{cart-38151cca.js → cart-f58c6575.js} +1 -1
- package/build/esm/components.js +1 -1
- package/build/esm/{en-669af913.js → en-2122556b.js} +0 -0
- package/build/esm/{get-17bc1d35.js → get-f6594d28.js} +0 -0
- package/build/esm/{i18n-2fdbe5db.js → i18n-88bbe1a1.js} +1 -1
- package/build/esm/{index-099b9743.js → index-10011dee.js} +1 -1
- package/build/esm/{index-ea9fc314.js → index-270f04f4.js} +1 -1
- package/build/esm/{index-94c469ed.js → index-b6ebc78e.js} +1 -1
- package/build/esm/{index-ac80179e.js → index-b8245ce8.js} +1 -1
- package/build/esm/{index-9ececcb5.js → index-c6779c48.js} +1 -1
- package/build/esm/{index-a1d85224.js → index-d47c16b6.js} +1 -1
- package/build/esm/{index-dbba4a4c.js → index-df1da9c5.js} +1 -1
- package/build/esm/{index-a93921be.js → index-f0720041.js} +1 -1
- package/build/esm/{index-6eb9d822.js → index-f4c9dbad.js} +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/models.js +1 -1
- package/build/esm/pages/[slug]/index.d.ts +0 -3
- package/build/esm/pages/[slug]/providers.d.ts +3 -0
- package/build/esm/pages/index.d.ts +2 -1
- package/build/esm/pages.js +1 -1
- package/build/esm/store.js +1 -1
- package/build/esm/{tr-69f8f304.js → tr-26d6f603.js} +0 -0
- package/build/esm/utils.js +1 -1
- package/package.json +1 -1
- package/build/cjs/blog-category-list-617dc467.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-f6594d28.js";import{aj as a,i as r,ah as o}from"./index-270f04f4.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 d,i as u}from"./get-17bc1d35.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-94c469ed.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-ea9fc314.js";import{IkasStorefrontConfig as M}from"./storefront.js";import{c as y,b as I,e as S}from"./index-ac80179e.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 d(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 d(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 d(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,u=this;return d(this,(function(d){switch(d.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===u.selectedPageComponentId})),this.selectedPageComponent.propValues[n]=t,this.pageDataProvider?[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,o)]:[2]):[2];case 1:return r=d.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 p(n,void 0,void 0,(function(){return d(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 d(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 d(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,d=n(null),c=M.store,l=M.currentPageComponents;t((function(){s.setComponentRef(d.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:u({},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,u({store:c},g,{settings:null===(e=s.theme)||void 0===e?void 0:e.settings,pageSpecificData:h.pageSpecificData}))}));return o("div",{ref:d,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 d=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)})),u=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,!!d&&o(b,{key:d.id,vm:p,pageComponent:d}),null==c?void 0:c.map((function(e){return o(b,{key:e.id,vm:p,pageComponent:e})}))),!!u&&o(b,{key:u.id,vm:p,pageComponent:u})))})),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 p,c as u,i as d}from"./get-f6594d28.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-b6ebc78e.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-270f04f4.js";import{IkasStorefrontConfig as M}from"./storefront.js";import{c as y,b as I,e as S}from"./index-b8245ce8.js";function L(n){var t=(void 0===n?{}:n).name;return e.createElement("div",{style:b},"Error! Please fill the component ",t," fields")}var w,b={lineHeight:"50px",textAlign:"center",fontSize:"16px",margin:"10px 0",border:"2px solid rgb(255, 0, 0)",backgroundColor:"rgba(255, 0, 0, 0.5)"},U=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 R=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 U(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(R,{key:u.id,vm:p,pageComponent:u}),null==c?void 0:c.map((function(e){return o(R,{key:e.id,vm:p,pageComponent:e})}))),!!d&&o(R,{key:d.id,vm:p,pageComponent:d})))})),x={minHeight:"100vh",width:"100vw",display:"flex",flexDirection:"column",justifyContent:"space-between"};export{G as I};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as n,c as e,e as t}from"./get-
|
|
1
|
+
import{_ as n,c as e,e as t}from"./get-f6594d28.js";import{z as i,i as a,ah as r,a8 as d,D as s}from"./index-270f04f4.js";var l,o,u=function(){function d(){}return d.listProductAttributes=function(d){return n(this,void 0,void 0,(function(){var n,s,o,u,c;return e(this,(function(e){switch(e.label){case 0:n=r(l||(l=t(["\n query listProductAttribute($id: StringFilterInput!) {\n listProductAttribute(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n description\n type\n options {\n id\n createdAt\n updatedAt\n deleted\n name\n }\n translations {\n description\n locale\n name\n options {\n id\n name\n }\n }\n }\n }\n "],["\n query listProductAttribute($id: StringFilterInput!) {\n listProductAttribute(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n description\n type\n options {\n id\n createdAt\n updatedAt\n deleted\n name\n }\n translations {\n description\n locale\n name\n options {\n id\n name\n }\n }\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{id:{in:d||[]}}})];case 2:return s=e.sent(),o=s.data,(u=s.errors)&&u.length?[2,[]]:[2,o.listProductAttribute.map((function(n){return new i(n)}))];case 3:return c=e.sent(),console.log(c),[3,4];case 4:return[2,[]]}}))}))},d}(),c=function(){function i(){}return i.listVariantTypes=function(i){return n(this,void 0,void 0,(function(){var n,l,u,c,p;return e(this,(function(e){switch(e.label){case 0:n=r(o||(o=t(["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n translations {\n locale\n name\n values {\n id\n name\n }\n }\n }\n }\n "],["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n translations {\n locale\n name\n values {\n id\n name\n }\n }\n }\n }\n "]))),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,a.getClient().query({query:n,variables:{id:{in:i||[]}}})];case 2:return l=e.sent(),u=l.data,(c=l.errors)&&c.length?[2,[]]:[2,u.listVariantType.map((function(n){return new d({id:n.id,name:n.name,selectionType:n.selectionType,values:n.values.map((function(e){return new s({id:e.id,name:e.name,colorCode:e.colorCode,thumbnailImageId:e.thumbnailImageId,variantTypeId:n.id})})),translations:n.translations})}))];case 3:return p=e.sent(),console.log(p),[3,4];case 4:return[2,[]]}}))}))},i}();export{u as I,c as a};
|