@gem-sdk/core 1.14.0-next.179 → 1.14.0-next.190
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/dist/cjs/components/ComponentWrapperPreview.js +1 -1
- package/dist/cjs/components/Render.liquid.js +15 -3
- package/dist/cjs/components/RenderCustomCode.js +5 -0
- package/dist/esm/components/ComponentWrapperPreview.js +1 -1
- package/dist/esm/components/Render.liquid.js +15 -3
- package/dist/esm/components/RenderCustomCode.js +5 -0
- package/dist/types/index.d.ts +5 -5
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),react=require("react"),composeAdvanceStyle=require("../helpers/compose-advance-style.js"),constant=require("./constant.js");const ComponentWrapperPreview=({children:e,...t})=>{if("section"===t.type)return null;let
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),react=require("react"),composeAdvanceStyle=require("../helpers/compose-advance-style.js"),constant=require("./constant.js"),RenderCustomCode=require("./RenderCustomCode.js");const ComponentWrapperPreview=({children:e,...t})=>{if("section"===t.type)return null;let n={};if(t.editorConfigs){let e=t.editorConfigs;e.placeholder?.notAppendBeforeAfter&&(n["data-placeholder-not-append-before-after"]=!0),e.toolbar?.parent&&(n["data-toolbar-parent"]=!0),e.component?.noDelete&&(n["data-component-no-delete"]=!0),e.component?.noDuplicate&&(n["data-component-no-duplicate"]=!0),e.component?.noDragDrop&&(n["data-component-no-drag-drop"]=!0),e.component?.noSetting&&(n["data-component-no-setting"]=!0),e.component?.isThirdParty&&(n["data-component-is-third-party"]=!0),e.toolbar?.hide&&(n["data-toolbar-hide"]=!0),e.slots?.children&&(n["data-slots-children"]=!0)}let o=composeAdvanceStyle.composeAdvanceStyle(t.advanced,t.tag),a=t.advanced,r={...n,"data-uid":t.uid,"data-component-type":"component","data-component-tag":t.tag,"data-component-label":t.label};return constant.disableWrap.includes(t.tag)&&react.isValidElement(e)?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{props:t}),jsxRuntime.jsx(e.type,{...e.props,style:o,builderAttrs:r,advanced:a})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(RenderCustomCode.default,{props:t}),jsxRuntime.jsx("div",{style:o,className:`${t.uid}`,...r,children:e})]})};exports.default=ComponentWrapperPreview;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("react"),require("swr");var render=require("../helpers/render.js");require("../helpers/convert.js");var composeAdvanceStyle=require("../helpers/compose-advance-style.js"),constant=require("./constant.js");const componentsRenderWithParentId=["CarouselItem"],componentTexts=["Text","Heading"],Render=({uid:e,builder:
|
|
2
|
-
${render.RenderIf(
|
|
3
|
-
</div
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("react"),require("swr");var render=require("../helpers/render.js");require("../helpers/convert.js");var composeAdvanceStyle=require("../helpers/compose-advance-style.js"),constant=require("./constant.js");const componentsRenderWithParentId=["CarouselItem"],componentTexts=["Text","Heading"],Render=({uid:e,builder:r,components:t,parentId:n,extraFiles:d={},...i})=>{let s=r[e],l=t[s?.tag];if(!l)return console.log("Miss component: ",s),{liquid:"",extraFiles:d};if(!s||s?.type==="section")return{liquid:"",extraFiles:d};{let d={extraFiles:{}},a=composeAdvanceStyle.composeAdvanceStyle(s.advanced,s.tag),o="";o=constant.disableWrap.includes(s.tag)?render.RenderIf(s?.childrens?.length,()=>l({builderProps:{uid:e,builderData:s},styles:s.styles,setting:s.settings,style:a,advanced:s.advanced,parentId:componentsRenderWithParentId.includes(s.tag)?n:null,...i,rawChildren:s.childrens.map(e=>({...r[e],uid:e,builder:r,components:t,customProps:d})),children:constant.customRenderChildren.includes(s.tag)?"":WrapRenderChildren({uid:e,customProps:d},s.childrens.map(e=>RenderChildren({uid:e,builder:r,components:t,customProps:d,parentTag:s.tag})))}),()=>l({builderProps:{uid:e,builderData:s},styles:s.styles,setting:s.settings,advanced:s.advanced,style:a,isText:!!componentTexts.includes(s.tag)||null,parentId:componentsRenderWithParentId.includes(s.tag)?n:null,...i})):render.template`<div style="${a}" class="${s.uid} ${s?.childrens?.length||"IconListItemHoz"!==s.tag?"":"hidden"}">
|
|
2
|
+
${render.RenderIf(s?.childrens?.length,()=>l({builderProps:{uid:e,builderData:s},styles:s.styles,setting:s.settings,...i,rawChildren:s.childrens.map(e=>({...r[e],uid:e,builder:r,components:t,customProps:d})),children:constant.customRenderChildren.includes(s.tag)?"":WrapRenderChildren({uid:e,customProps:d},s.childrens.map(e=>RenderChildren({uid:e,builder:r,components:t,customProps:d,parentTag:s.tag})))}),()=>l({builderProps:{uid:e,builderData:s},styles:s.styles,setting:s.settings,isText:!!componentTexts.includes(s.tag)||null,...i}))}
|
|
3
|
+
</div>`;let{cssCode:c,jsCode:u}=RenderCustomCode(s);return c&&(o+=c),u&&(o+=u),{liquid:o,extraFiles:d.extraFiles}}},RenderCustomCode=e=>{let{css:r,javascript:t}=e.advanced?.editorData||{},n=render.RenderIf(!!r,render.template`
|
|
4
|
+
<style
|
|
5
|
+
id="${`custom-css-${e?.uid}`}"
|
|
6
|
+
>${r}</style>
|
|
7
|
+
`),d=render.RenderIf(!!t,render.template`
|
|
8
|
+
<script
|
|
9
|
+
id="${`custom-js-${e?.uid}`}"
|
|
10
|
+
>
|
|
11
|
+
try {
|
|
12
|
+
${t}
|
|
13
|
+
} catch(err){}
|
|
14
|
+
</script>
|
|
15
|
+
`);return{cssCode:n,jsCode:d}},RenderChildren=e=>{let r=Render(e);for(let t in r.extraFiles)if(Object.prototype.hasOwnProperty.call(r.extraFiles,t)){let n=r.extraFiles[t];e.customProps.extraFiles[t]=n}let t=new TextEncoder,n=r?.liquid?t.encode(r.liquid).length:0;if(Math.ceil(n/1024)>=180){let t=`gp-section-snippet-${e.uid}`;return e.customProps.extraFiles[t]=r.liquid,`{% render '${t}', product: product, variant: variant, product_form_id: product_form_id %}`}return r.liquid},WrapRenderChildren=({uid:e,customProps:r},t)=>{let n="";if(t?.length)for(let d=0;d<t.length;d++){let i=t[d];if(i){let t=n+i,s=new TextEncoder,l=t?s.encode(t).length:0;if(Math.ceil(l/1024)>=180){let t=`gp-section-snippet-${e+d}`;r.extraFiles[t]=i,n+=`{% render '${t}', product: product, variant: variant, product_form_id: product_form_id %}`}else n+=i}}return n};exports.RenderChildren=RenderChildren,exports.WrapRenderChildren=WrapRenderChildren,exports.default=Render;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),Head=require("next/head"),Script=require("next/script"),react=require("react");require("zustand"),require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation");var shop=require("../hooks/shop.js");require("vanilla-lazyload"),require("../hooks/useCartUI.js"),require("../helpers/convert.js");const RenderCustomCode=({props:e})=>{let r=shop.useEditorMode(),{css:s,javascript:t}=e?.advanced?.editorData||{},i={css:`custom-css-${e?.uid}`,javascript:`custom-js-${e?.uid}`},u=react.useMemo(()=>`
|
|
2
|
+
try {
|
|
3
|
+
${t}
|
|
4
|
+
} catch(err){}
|
|
5
|
+
`,[t]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Head,{children:!!s&&jsxRuntime.jsx("style",{id:i.css,dangerouslySetInnerHTML:{__html:s}})}),!!t&&"edit"!==r&&jsxRuntime.jsx(Script,{id:i.javascript,dangerouslySetInnerHTML:{__html:u}})]})};exports.default=RenderCustomCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as o}from"react/jsx-runtime";import{isValidElement as n}from"react";import{composeAdvanceStyle as a}from"../helpers/compose-advance-style.js";import{disableWrap as r}from"./constant.js";import p from"./RenderCustomCode.js";let ComponentWrapperPreview=({children:d,...i})=>{if("section"===i.type)return null;let l={};if(i.editorConfigs){let e=i.editorConfigs;e.placeholder?.notAppendBeforeAfter&&(l["data-placeholder-not-append-before-after"]=!0),e.toolbar?.parent&&(l["data-toolbar-parent"]=!0),e.component?.noDelete&&(l["data-component-no-delete"]=!0),e.component?.noDuplicate&&(l["data-component-no-duplicate"]=!0),e.component?.noDragDrop&&(l["data-component-no-drag-drop"]=!0),e.component?.noSetting&&(l["data-component-no-setting"]=!0),e.component?.isThirdParty&&(l["data-component-is-third-party"]=!0),e.toolbar?.hide&&(l["data-toolbar-hide"]=!0),e.slots?.children&&(l["data-slots-children"]=!0)}let c=a(i.advanced,i.tag),m=i.advanced,s={...l,"data-uid":i.uid,"data-component-type":"component","data-component-tag":i.tag,"data-component-label":i.label};return r.includes(i.tag)&&n(d)?e(t,{children:[o(p,{props:i}),o(d.type,{...d.props,style:c,builderAttrs:s,advanced:m})]}):e(t,{children:[o(p,{props:i}),o("div",{style:c,className:`${i.uid}`,...s,children:d})]})};export{ComponentWrapperPreview as default};
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import"react";import"swr";import{RenderIf as e,template as t}from"../helpers/render.js";import"../helpers/convert.js";import{composeAdvanceStyle as r}from"../helpers/compose-advance-style.js";import{disableWrap as n,customRenderChildren as i}from"./constant.js";let componentsRenderWithParentId=["CarouselItem"],componentTexts=["Text","Heading"],Render=({uid:d,builder:
|
|
2
|
-
${e(p?.childrens?.length,()=>u({builderProps:{uid:d,builderData:p},styles:p.styles,setting:p.settings,...c,rawChildren:p.childrens.map(e=>({...
|
|
3
|
-
</div
|
|
1
|
+
import"react";import"swr";import{RenderIf as e,template as t}from"../helpers/render.js";import"../helpers/convert.js";import{composeAdvanceStyle as r}from"../helpers/compose-advance-style.js";import{disableWrap as n,customRenderChildren as i}from"./constant.js";let componentsRenderWithParentId=["CarouselItem"],componentTexts=["Text","Heading"],Render=({uid:d,builder:s,components:l,parentId:a,extraFiles:o={},...c})=>{let p=s[d],u=l[p?.tag];if(!u)return console.log("Miss component: ",p),{liquid:"",extraFiles:o};if(!p||p?.type==="section")return{liquid:"",extraFiles:o};{let o={extraFiles:{}},h=r(p.advanced,p.tag),g="";g=n.includes(p.tag)?e(p?.childrens?.length,()=>u({builderProps:{uid:d,builderData:p},styles:p.styles,setting:p.settings,style:h,advanced:p.advanced,parentId:componentsRenderWithParentId.includes(p.tag)?a:null,...c,rawChildren:p.childrens.map(e=>({...s[e],uid:e,builder:s,components:l,customProps:o})),children:i.includes(p.tag)?"":WrapRenderChildren({uid:d,customProps:o},p.childrens.map(e=>RenderChildren({uid:e,builder:s,components:l,customProps:o,parentTag:p.tag})))}),()=>u({builderProps:{uid:d,builderData:p},styles:p.styles,setting:p.settings,advanced:p.advanced,style:h,isText:!!componentTexts.includes(p.tag)||null,parentId:componentsRenderWithParentId.includes(p.tag)?a:null,...c})):t`<div style="${h}" class="${p.uid} ${p?.childrens?.length||"IconListItemHoz"!==p.tag?"":"hidden"}">
|
|
2
|
+
${e(p?.childrens?.length,()=>u({builderProps:{uid:d,builderData:p},styles:p.styles,setting:p.settings,...c,rawChildren:p.childrens.map(e=>({...s[e],uid:e,builder:s,components:l,customProps:o})),children:i.includes(p.tag)?"":WrapRenderChildren({uid:d,customProps:o},p.childrens.map(e=>RenderChildren({uid:e,builder:s,components:l,customProps:o,parentTag:p.tag})))}),()=>u({builderProps:{uid:d,builderData:p},styles:p.styles,setting:p.settings,isText:!!componentTexts.includes(p.tag)||null,...c}))}
|
|
3
|
+
</div>`;let{cssCode:m,jsCode:x}=RenderCustomCode(p);return m&&(g+=m),x&&(g+=x),{liquid:g,extraFiles:o.extraFiles}}},RenderCustomCode=r=>{let{css:n,javascript:i}=r.advanced?.editorData||{},d=e(!!n,t`
|
|
4
|
+
<style
|
|
5
|
+
id="${`custom-css-${r?.uid}`}"
|
|
6
|
+
>${n}</style>
|
|
7
|
+
`),s=e(!!i,t`
|
|
8
|
+
<script
|
|
9
|
+
id="${`custom-js-${r?.uid}`}"
|
|
10
|
+
>
|
|
11
|
+
try {
|
|
12
|
+
${i}
|
|
13
|
+
} catch(err){}
|
|
14
|
+
</script>
|
|
15
|
+
`);return{cssCode:d,jsCode:s}},RenderChildren=e=>{let t=Render(e);for(let r in t.extraFiles)if(Object.prototype.hasOwnProperty.call(t.extraFiles,r)){let n=t.extraFiles[r];e.customProps.extraFiles[r]=n}let r=new TextEncoder,n=t?.liquid?r.encode(t.liquid).length:0;if(Math.ceil(n/1024)>=180){let r=`gp-section-snippet-${e.uid}`;return e.customProps.extraFiles[r]=t.liquid,`{% render '${r}', product: product, variant: variant, product_form_id: product_form_id %}`}return t.liquid},WrapRenderChildren=({uid:e,customProps:t},r)=>{let n="";if(r?.length)for(let i=0;i<r.length;i++){let d=r[i];if(d){let r=n+d,s=new TextEncoder,l=r?s.encode(r).length:0;if(Math.ceil(l/1024)>=180){let r=`gp-section-snippet-${e+i}`;t.extraFiles[r]=d,n+=`{% render '${r}', product: product, variant: variant, product_form_id: product_form_id %}`}else n+=d}}return n};export{RenderChildren,WrapRenderChildren,Render as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{jsxs as t,Fragment as r,jsx as e}from"react/jsx-runtime";import o from"next/head";import s from"next/script";import{useMemo as i}from"react";import"zustand";import"swr";import"@gem-sdk/adapter-shopify";import"swr/mutation";import{useEditorMode as m}from"../hooks/shop.js";import"vanilla-lazyload";import"../hooks/useCartUI.js";import"../helpers/convert.js";let RenderCustomCode=({props:a})=>{let d=m(),{css:p,javascript:n}=a?.advanced?.editorData||{},c={css:`custom-css-${a?.uid}`,javascript:`custom-js-${a?.uid}`},l=i(()=>`
|
|
2
|
+
try {
|
|
3
|
+
${n}
|
|
4
|
+
} catch(err){}
|
|
5
|
+
`,[n]);return t(r,{children:[e(o,{children:!!p&&e("style",{id:c.css,dangerouslySetInnerHTML:{__html:p}})}),!!n&&"edit"!==d&&e(s,{id:c.javascript,dangerouslySetInnerHTML:{__html:l}})]})};export{RenderCustomCode as default};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9405,7 +9405,7 @@ type RequiredCursorEdge<T> = {
|
|
|
9405
9405
|
};
|
|
9406
9406
|
declare const fetchVariants: (fetcher: FetchFunc, { id, isSample, isStorefront }: FetchProductParams) => Promise<RequiredCursorEdge<VariantSelectFragment>[]>;
|
|
9407
9407
|
declare const fetchMedias: (fetcher: FetchFunc, { id, isSample, isStorefront }: FetchProductParams) => Promise<(Pick<MediaEdge, "cursor"> & {
|
|
9408
|
-
node?: Maybe<Pick<Media, "width" | "height" | "id" | "
|
|
9408
|
+
node?: Maybe<Pick<Media, "width" | "height" | "id" | "src" | "alt" | "contentType" | "previewImage">>;
|
|
9409
9409
|
})[]>;
|
|
9410
9410
|
|
|
9411
9411
|
type FetchProductsParams = {
|
|
@@ -9600,13 +9600,13 @@ declare const useSelectedOption: () => {
|
|
|
9600
9600
|
setSelectedOption: (optionId?: Maybe<string>, optionValue?: Maybe<string>) => void;
|
|
9601
9601
|
forceSelectedOption: (value?: Record<string, any> | undefined) => void;
|
|
9602
9602
|
};
|
|
9603
|
-
declare const useVariants: () => Maybe<Pick<ProductVariant, "title" | "width" | "length" | "weight" | "height" | "id" | "
|
|
9603
|
+
declare const useVariants: () => Maybe<Pick<ProductVariant, "title" | "width" | "length" | "weight" | "height" | "id" | "baseID" | "platform" | "sku" | "barcode" | "costPrice" | "inventoryPolicy" | "inventoryQuantity" | "inventoryStatus" | "isDigital" | "lowInventoryAmount" | "manageInventory" | "mediaId" | "price" | "salePrice" | "soldIndividually"> & {
|
|
9604
9604
|
selectedOptions: Pick<SelectedOption, "value" | "name" | "optionType">[];
|
|
9605
|
-
media?: Maybe<Pick<Media, "width" | "height" | "id" | "
|
|
9605
|
+
media?: Maybe<Pick<Media, "width" | "height" | "id" | "src" | "alt" | "contentType" | "previewImage">>;
|
|
9606
9606
|
}>[];
|
|
9607
|
-
declare const useVariant: (id: string) => Maybe<Pick<ProductVariant, "title" | "width" | "length" | "weight" | "height" | "id" | "
|
|
9607
|
+
declare const useVariant: (id: string) => Maybe<Pick<ProductVariant, "title" | "width" | "length" | "weight" | "height" | "id" | "baseID" | "platform" | "sku" | "barcode" | "costPrice" | "inventoryPolicy" | "inventoryQuantity" | "inventoryStatus" | "isDigital" | "lowInventoryAmount" | "manageInventory" | "mediaId" | "price" | "salePrice" | "soldIndividually"> & {
|
|
9608
9608
|
selectedOptions: Pick<SelectedOption, "value" | "name" | "optionType">[];
|
|
9609
|
-
media?: Maybe<Pick<Media, "width" | "height" | "id" | "
|
|
9609
|
+
media?: Maybe<Pick<Media, "width" | "height" | "id" | "src" | "alt" | "contentType" | "previewImage">>;
|
|
9610
9610
|
}>;
|
|
9611
9611
|
declare const useCurrentVariant: () => Maybe<VariantSelectFragment>;
|
|
9612
9612
|
declare const useCurrentVariantInStock: () => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/core",
|
|
3
|
-
"version": "1.14.0-next.
|
|
3
|
+
"version": "1.14.0-next.190",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@gem-sdk/adapter-shopify": "1.12.0",
|
|
28
|
-
"@gem-sdk/styles": "1.14.0-next.
|
|
28
|
+
"@gem-sdk/styles": "1.14.0-next.184"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"react-error-boundary": "4.0.10",
|