@lightspeed/crane 1.2.5 → 1.3.0

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.
Files changed (27) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/app.d.mts +23 -10
  3. package/dist/app.d.ts +23 -10
  4. package/dist/app.mjs +1 -1
  5. package/dist/cli.mjs +7 -7
  6. package/package.json +13 -13
  7. package/template/layouts/catalog/example-catalog/Main.vue +1 -1
  8. package/template/layouts/catalog/example-catalog/assets/account-icon.svg +11 -0
  9. package/template/layouts/catalog/example-catalog/components/Icon.vue +52 -0
  10. package/template/layouts/catalog/example-catalog/settings/content.ts +1 -0
  11. package/template/layouts/catalog/example-catalog/settings/design.ts +1 -0
  12. package/template/layouts/catalog/example-catalog/settings/translations.ts +1 -0
  13. package/template/layouts/catalog/example-catalog/slots/custom-bottom-bar/CustomBottomBar.vue +69 -0
  14. package/template/layouts/catalog/example-catalog/slots/custom-bottom-bar/client.ts +5 -0
  15. package/template/layouts/catalog/example-catalog/slots/custom-bottom-bar/server.ts +5 -0
  16. package/template/layouts/catalog/example-catalog/type.ts +5 -0
  17. package/template/layouts/category/example-category/settings/content.ts +1 -0
  18. package/template/layouts/category/example-category/settings/design.ts +1 -0
  19. package/template/layouts/category/example-category/type.ts +5 -0
  20. package/template/layouts/product/example-product/settings/content.ts +1 -0
  21. package/template/layouts/product/example-product/settings/design.ts +1 -0
  22. package/template/layouts/product/example-product/type.ts +5 -0
  23. package/template/page-templates/example-template/pages/catalog.ts +5 -4
  24. package/template/page-templates/example-template/pages/category.ts +5 -4
  25. package/template/page-templates/example-template/pages/product.ts +5 -4
  26. package/template/preview/sections/preview.html +52 -4
  27. package/template/preview/shared/utils.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.7 - 2025-09-01
4
+
5
+ ### Added
6
+
7
+ - Hot reload support for local preview.
8
+
9
+ ### Changed
10
+
11
+ - Update version of 'axios' dependency.
12
+
13
+ ## 1.2.6 - 2025-08-06
14
+
15
+ ### Added
16
+
17
+ - **Storefront (experimental):** add support for custom slots in storefront page layouts.
18
+
3
19
  ## 1.2.5 - 2025-07-07
4
20
 
5
21
  ### Added
package/dist/app.d.mts CHANGED
@@ -204,8 +204,17 @@ declare function useDeckElementContent<CONTENT>(elementName: keyof CONTENT): {
204
204
  getReactiveRef: typeof getReactiveRef;
205
205
  };
206
206
  declare function getReactiveRef(card: Card | undefined, editorType: EditorTypes, contentElementName: string): {
207
+ hasContent: boolean;
208
+ value: boolean | undefined;
209
+ } | {
207
210
  hasContent: boolean;
208
211
  value: string | undefined;
212
+ } | {
213
+ hasContent: boolean;
214
+ lowResolutionMobileImage: string;
215
+ highResolutionMobileImage: string;
216
+ lowResolutionDesktopImage: string;
217
+ highResolutionDesktopImage: string;
209
218
  } | {
210
219
  title: string | undefined;
211
220
  type: ActionLinkType | undefined;
@@ -218,15 +227,6 @@ declare function getReactiveRef(card: Card | undefined, editorType: EditorTypes,
218
227
  hasTitle: boolean;
219
228
  hasLink: boolean;
220
229
  performAction: (() => void) | undefined;
221
- } | {
222
- hasContent: boolean;
223
- value: boolean | undefined;
224
- } | {
225
- hasContent: boolean;
226
- lowResolutionMobileImage: string;
227
- highResolutionMobileImage: string;
228
- lowResolutionDesktopImage: string;
229
- highResolutionDesktopImage: string;
230
230
  } | undefined;
231
231
 
232
232
  declare function useLogoElementContent<CONTENT>(): {
@@ -384,14 +384,26 @@ interface InstantsiteJSAPI {
384
384
 
385
385
  declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
386
386
 
387
+ interface StorefrontSection {
388
+ /** Section layout identifier. When not provided, the section will use the default layout. */
389
+ readonly id?: string;
390
+ readonly type: 'store';
391
+ }
392
+
393
+ interface StorePageConfiguration {
394
+ readonly sections: [StorefrontSection];
395
+ }
396
+
387
397
  declare const CatalogLayoutSlot: {
388
398
  readonly PRODUCT_LIST: "CONTROLS";
389
399
  readonly BOTTOM_BAR: "FOOTER";
400
+ readonly CUSTOM_SLOT: "CUSTOM_SLOT";
390
401
  };
391
402
  declare const CategoryLayoutSlot: {
392
403
  readonly CATEGORY_TITLE: "MAIN_TITLE";
393
404
  readonly PRODUCT_LIST: "CONTROLS";
394
405
  readonly BOTTOM_BAR: "FOOTER";
406
+ readonly CUSTOM_SLOT: "CUSTOM_SLOT";
395
407
  };
396
408
  declare const ProductLayoutSlot: {
397
409
  readonly TOP_BAR: "TOP_BAR";
@@ -401,7 +413,8 @@ declare const ProductLayoutSlot: {
401
413
  readonly REVIEW_LIST: "REVIEW_LIST";
402
414
  readonly RELATED_PRODUCTS: "RELATED_PRODUCTS";
403
415
  readonly BOTTOM_BAR: "FOOTER";
416
+ readonly CUSTOM_SLOT: "CUSTOM_SLOT";
404
417
  };
405
418
 
406
419
  export { CatalogLayoutSlot, CategoryLayoutSlot, EditorTypes, ProductLayoutSlot, createVueClientApp, createVueServerApp, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useDeckElementContent, useImageElementContent, useImageElementDesign, useInputboxElementContent, useInstantsiteJsApi, useLayoutElementDesign, useLogoElementContent, useLogoElementDesign, useMenuElementContent, useNavigationMenuElementContent, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useTextareaElementDesign, useToggleElementContent, useToggleElementDesign, useVueBaseProps };
407
- export type { ButtonContent, Card, Deck, ImageContent, InputBoxContent, SelectBoxContent, TextAreaContent, ToggleContent };
420
+ export type { ButtonContent, Card, Deck, ImageContent, InputBoxContent, SelectBoxContent, StorePageConfiguration, TextAreaContent, ToggleContent };
package/dist/app.d.ts CHANGED
@@ -204,8 +204,17 @@ declare function useDeckElementContent<CONTENT>(elementName: keyof CONTENT): {
204
204
  getReactiveRef: typeof getReactiveRef;
205
205
  };
206
206
  declare function getReactiveRef(card: Card | undefined, editorType: EditorTypes, contentElementName: string): {
207
+ hasContent: boolean;
208
+ value: boolean | undefined;
209
+ } | {
207
210
  hasContent: boolean;
208
211
  value: string | undefined;
212
+ } | {
213
+ hasContent: boolean;
214
+ lowResolutionMobileImage: string;
215
+ highResolutionMobileImage: string;
216
+ lowResolutionDesktopImage: string;
217
+ highResolutionDesktopImage: string;
209
218
  } | {
210
219
  title: string | undefined;
211
220
  type: ActionLinkType | undefined;
@@ -218,15 +227,6 @@ declare function getReactiveRef(card: Card | undefined, editorType: EditorTypes,
218
227
  hasTitle: boolean;
219
228
  hasLink: boolean;
220
229
  performAction: (() => void) | undefined;
221
- } | {
222
- hasContent: boolean;
223
- value: boolean | undefined;
224
- } | {
225
- hasContent: boolean;
226
- lowResolutionMobileImage: string;
227
- highResolutionMobileImage: string;
228
- lowResolutionDesktopImage: string;
229
- highResolutionDesktopImage: string;
230
230
  } | undefined;
231
231
 
232
232
  declare function useLogoElementContent<CONTENT>(): {
@@ -384,14 +384,26 @@ interface InstantsiteJSAPI {
384
384
 
385
385
  declare function useInstantsiteJsApi(): InstantsiteJSAPI | undefined;
386
386
 
387
+ interface StorefrontSection {
388
+ /** Section layout identifier. When not provided, the section will use the default layout. */
389
+ readonly id?: string;
390
+ readonly type: 'store';
391
+ }
392
+
393
+ interface StorePageConfiguration {
394
+ readonly sections: [StorefrontSection];
395
+ }
396
+
387
397
  declare const CatalogLayoutSlot: {
388
398
  readonly PRODUCT_LIST: "CONTROLS";
389
399
  readonly BOTTOM_BAR: "FOOTER";
400
+ readonly CUSTOM_SLOT: "CUSTOM_SLOT";
390
401
  };
391
402
  declare const CategoryLayoutSlot: {
392
403
  readonly CATEGORY_TITLE: "MAIN_TITLE";
393
404
  readonly PRODUCT_LIST: "CONTROLS";
394
405
  readonly BOTTOM_BAR: "FOOTER";
406
+ readonly CUSTOM_SLOT: "CUSTOM_SLOT";
395
407
  };
396
408
  declare const ProductLayoutSlot: {
397
409
  readonly TOP_BAR: "TOP_BAR";
@@ -401,7 +413,8 @@ declare const ProductLayoutSlot: {
401
413
  readonly REVIEW_LIST: "REVIEW_LIST";
402
414
  readonly RELATED_PRODUCTS: "RELATED_PRODUCTS";
403
415
  readonly BOTTOM_BAR: "FOOTER";
416
+ readonly CUSTOM_SLOT: "CUSTOM_SLOT";
404
417
  };
405
418
 
406
419
  export { CatalogLayoutSlot, CategoryLayoutSlot, EditorTypes, ProductLayoutSlot, createVueClientApp, createVueServerApp, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useDeckElementContent, useImageElementContent, useImageElementDesign, useInputboxElementContent, useInstantsiteJsApi, useLayoutElementDesign, useLogoElementContent, useLogoElementDesign, useMenuElementContent, useNavigationMenuElementContent, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useTextareaElementDesign, useToggleElementContent, useToggleElementDesign, useVueBaseProps };
407
- export type { ButtonContent, Card, Deck, ImageContent, InputBoxContent, SelectBoxContent, TextAreaContent, ToggleContent };
420
+ export type { ButtonContent, Card, Deck, ImageContent, InputBoxContent, SelectBoxContent, StorePageConfiguration, TextAreaContent, ToggleContent };
package/dist/app.mjs CHANGED
@@ -1 +1 @@
1
- import{getCurrentInstance as M,ref as b,computed as i,reactive as d,createSSRApp as U}from"vue";import{renderToString as K}from"vue/server-renderer";const w=new Map;function c(){const e=(l,r,a,v,g,s,u)=>{w.set(l._uid,{context:b(r),content:b(a),design:b(v),defaults:b(g),site:b(s?.site??{}),category:b(s?.category),globalDesign:b(u)})},n=(l,r,a,v,g,s)=>{const u=w.get(l._uid);u!==void 0&&(u.content.value=r,u.design.value=a,u.defaults.value=v,u.site.value=g.site??{},u.category.value=g.category,u.globalDesign.value=s)},t=M()?.appContext.app._uid??-1,o=w.get(t);return{init:e,update:n,context:o?.context,content:o?.content,design:o?.design,defaults:o?.defaults,site:o?.site,category:o?.category,globalDesign:o?.globalDesign}}function R(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return F(o,e)}function F(e,n){const t=i(()=>{const r=e.value[n];if(r!==void 0){if(typeof r=="string")return r;throw new Error(`Element ${n} is not inputbox`)}}),o=i(()=>t.value!==void 0),l=i(()=>t.value);return d({hasContent:o,value:l})}function C(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return W(o,e)}function W(e,n){const t=i(()=>{const r=e.value[n];if(r!==void 0){if(typeof r=="string")return r;throw new Error(`Element ${n} is not textarea`)}}),o=i(()=>t.value!==void 0),l=i(()=>t.value);return d({hasContent:o,value:l})}const E={HYPER_LINK:"HYPER_LINK",SCROLL_TO_TILE:"SCROLL_TO_TILE",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY"};function X(e){if("tileId"in e)return e.tileId;if("tileIdForScroll"in e)return e.tileIdForScroll}function Y(e){if("pageId"in e)return e.pageId;if("pageIdForNavigate"in e)return e.pageIdForNavigate}function V(e){if("pageUrl"in e)return e.pageUrl;switch(Y(e)){case"products":return"/products";case"cart":return"/cart";case"account":return"/account";case"search":return"/search";case"home":default:return"/"}}const L=(e,n)=>{if(!e||n)return;const{type:t,link:o,email:l,phone:r}=e,a=V(e);switch(t){case E.HYPER_LINK:if(o)return()=>window.open(o,"_blank");break;case E.GO_TO_STORE:case E.GO_TO_STORE_LINK:return()=>window.open("/products","_self");case E.MAIL_LINK:if(l)return()=>window.open(`mailto:${l}`,"_self");break;case E.TEL_LINK:if(r)return()=>window.open(`tel:${r}`,"_self");break;case E.SCROLL_TO_TILE:if(typeof document<"u")return()=>{const v=X(e);document.getElementById(`tile-${v}`)?.scrollIntoView()};break;case E.GO_TO_PAGE:if(a)return()=>window.open(a,"_self");break;default:console.error(`Unknown type of ActionLink: ${t}`)}};function H(e){return"title"in e&&"type"in e}function j(e,n,t){const o=i(()=>{const _=e.value[n];if(_!==void 0){if(H(_))return _;throw new Error(`Element ${n} is not action link`)}}),l=i(()=>o.value?.title),r=i(()=>o.value?.type),a=i(()=>o.value?.link),v=i(()=>o.value?.email),g=i(()=>o.value?.phone),s=i(()=>o.value?.tileId?`tile-${o.value?.tileId}`:null),u=i(()=>o.value?.type==="GO_TO_STORE_LINK"?"products":o.value?.pageId),f=i(()=>o.value?.pageUrl),m=i(()=>!!l.value),$=i(()=>!!a.value),P=L(o.value,t);return d({title:l,type:r,link:a,email:v,phone:g,tileDivId:s,pageId:u,pageUrl:f,hasTitle:m,hasLink:$,performAction:P})}function h(e,n){const t=c(),o=i(()=>!!t.site?.value?.isPreviewMode),l=i(()=>n!==void 0?n:t.content.value!==void 0?t.content.value:{});return j(l,e,o.value)}function J(e){return"bucket"in e&&"borderInfo"in e&&"set"in e}function T(e,n){const t=new RegExp(/^https?:\/\//);return e!=null&&t.test(e)?e:`${n}/${e}`}function D(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return q(o,e)}function q(e,n){const t=i(()=>{const s=e.value[n];if(s!==void 0){if(J(s))return s;throw new Error(`Element ${n} is not image`)}}),o=i(()=>t.value===void 0?"":c().context.value.imageBuckets?.[t.value?.bucket]),l=i(()=>t.value!==void 0),r=i(()=>T(t.value?.set?.["cropped-webp-100x200"]?.url,o.value)),a=i(()=>T(t.value?.set?.["cropped-webp-1000x2000"]?.url,o.value)),v=i(()=>T(t.value?.set?.["webp-200x200"]?.url,o.value)),g=i(()=>T(t.value?.set?.["webp-2000x2000"]?.url,o.value));return d({hasContent:l,lowResolutionMobileImage:r,highResolutionMobileImage:a,lowResolutionDesktopImage:v,highResolutionDesktopImage:g})}function Q(e){return"enabled"in e}function A(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return Z(o,e)}function Z(e,n){const t=i(()=>{const r=e.value[n];if(r!==void 0){if(Q(r))return r;throw new Error(`Element ${n} is not toggle`)}}),o=i(()=>t.value!==void 0),l=i(()=>t.value?.enabled);return d({hasContent:o,value:l})}function S(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return ee(o,e)}function ee(e,n){const t=i(()=>{const r=e.value[n];if(r!==void 0){if(typeof r=="string")return r;throw new Error(`Element ${n} is not selectbox`)}}),o=i(()=>t.value!==void 0),l=i(()=>t.value);return d({hasContent:o,value:l})}function te(e){return e!==null&&"items"in e}function x(e){const n=c(),t=i(()=>{const a=n.content.value[e];if(a!==void 0){if(te(a))return a;throw new Error(`Element ${e} is not an menu`)}}),o=i(()=>!!n.site?.value?.isPreviewMode),l=i(()=>t.value!==void 0),r=i(()=>t.value?.items?t.value.items.map(a=>({...a,performAction:L(a,o.value)})):[]);return d({hasContent:l,items:r})}const ne="menu";function oe(){return x(ne)}var k=(e=>(e.INPUTBOX="INPUTBOX",e.TEXTAREA="TEXTAREA",e.BUTTON="BUTTON",e.IMAGE="IMAGE",e.TOGGLE="TOGGLE",e.SELECTBOX="SELECTBOX",e))(k||{});function ie(e){if(typeof e!="object"||e===null)return!1;const n=e;return Array.isArray(n.cards)&&n.cards.every(t=>typeof t.settings=="object"&&t.settings!==null)}function le(e){const n=c(),t=i(()=>{const r=n.content.value[e];if(r!==void 0){if(ie(r))return r;throw new Error(`Element ${e} is not of DECK type`)}}),o=i(()=>t.value!==void 0&&t.value.cards.length>0),l=i(()=>t.value?.cards);return d({hasContent:o,cards:l,getReactiveRef:re})}function re(e,n,t){if(e==null)throw Error("Could not get a reactive ref for undefined Card");const o=e.settings[t];if(o===void 0)return o;switch(n){case"TEXTAREA":return C(t,e.settings);case"INPUTBOX":return R(t,e.settings);case"SELECTBOX":return S(t,e.settings);case"IMAGE":return D(t,e.settings);case"TOGGLE":return A(t,e.settings);case"BUTTON":return h(t,e.settings);default:return}}function ae(e){return"type"in e&&("text"in e||"image"in e)}function O(e,n){const t=new RegExp(/^https?:\/\//);return e!==void 0&&t.test(e)?e:`${n}/${e}`}function ue(){const e=c(),n=i(()=>{const a=e.content.value.logo;if(a!==void 0){if(ae(a))return a;throw new Error("Element logo is not LOGO")}}),t=i(()=>n.value?.type),o=i(()=>n.value?.text),l=i(()=>n.value?.image===void 0?"":e.context.value.imageBuckets?.[n.value.image.bucket]),r=i(()=>({lowResolutionMobileImage:O(n.value?.image?.set?.["cropped-webp-100x200"]?.url,l.value),highResolutionMobileImage:O(n.value?.image?.set?.["cropped-webp-1000x2000"]?.url,l.value),lowResolutionDesktopImage:O(n.value?.image?.set?.["webp-200x200"]?.url,l.value),highResolutionDesktopImage:O(n.value?.image?.set?.["webp-2000x2000"]?.url,l.value)}));return d({type:t,text:o,image:r})}function G(e,n){if(n===void 0)return;if(!n.startsWith("global."))return n.replaceAll("_"," ");const t=n.split(".").at(2);if(t!==void 0)return e.fontFamily?e.fontFamily[t].replaceAll("_"," "):void 0}function I(e,n,t){return n?G(e,n):G(e,t)}function N(e,n){if(n===void 0)return;if(typeof n!="string"||!n.startsWith("global."))return n;const t=n.split(".").at(2);if(t!==void 0)return e.textSize?e.textSize[t]:void 0}function y(e,n,t){return n?N(e,n):N(e,t)}function B(e,n){if(n===void 0)return;if(typeof n!="string"||!n.startsWith("global."))return n;const t=n.split(".").at(2);if(t!==void 0)return e.color?e.color[t]:void 0}function p(e,n,t){return n?B(e,n):B(e,t)}function se(e,n,t){return{visible:n?.visible??t?.visible??!1,width:n?.width??t?.width??1,color:p(e,n?.color,t?.color)}}function ce(e){const n=c(),t=i(()=>{const s=n.design.value[e],u=n.defaults.value[e],f=n.globalDesign.value;return{font:I(f,s?.font,u?.font),size:y(f,s?.size,u?.size),bold:s?.bold??u?.bold,italic:s?.italic??u?.italic,color:p(f,s?.color,u?.color),visible:s?.visible??u?.visible??!1}}),o=i(()=>t.value?.font),l=i(()=>t.value?.size),r=i(()=>t.value?.bold),a=i(()=>t.value?.italic),v=i(()=>t.value?.color),g=i(()=>t.value?.visible);return d({font:o,size:l,bold:r,italic:a,color:v,visible:g})}function ve(e){const n=c(),t=i(()=>{const u=n.design.value[e],f=n.defaults.value[e],m=n.globalDesign.value;return{font:I(m,u?.font,f?.font),size:y(m,u?.size,f?.size),bold:u?.bold??f?.bold,italic:u?.italic??f?.italic,color:p(m,u?.color,f?.color),visible:u?.visible??f?.visible??!1,whiteSpace:"pre-wrap"}}),o=i(()=>t.value?.font),l=i(()=>t.value?.size),r=i(()=>t.value?.bold),a=i(()=>t.value?.italic),v=i(()=>t.value?.color),g=i(()=>t.value?.visible),s=i(()=>t.value?.whiteSpace);return d({font:o,size:l,bold:r,italic:a,color:v,visible:g,whiteSpace:s})}function de(e){const n=c(),t=i(()=>{const s=n.design.value[e],u=n.defaults.value[e],f=n.globalDesign.value;return{appearance:s?.appearance??u?.appearance,font:I(f,s?.font,u?.font),size:s?.size??u?.size,style:s?.style??u?.style,color:p(f,s?.color,u?.color),visible:s?.visible??u?.visible??!1}}),o=i(()=>t.value?.appearance),l=i(()=>t.value?.font),r=i(()=>t.value?.size),a=i(()=>t.value?.style),v=i(()=>t.value?.color),g=i(()=>t.value?.visible);return d({appearance:o,font:l,size:r,style:a,color:v,visible:g})}function fe(e){const n=c(),t=i(()=>{const r=n.design.value[e],a=n.defaults.value[e],v=n.globalDesign.value;return{overlay:{type:r?.overlay?.type??a?.overlay?.type,solid:{color:p(v,r?.overlay?.solid?.color,a?.overlay?.solid?.color)},gradient:{fromColor:p(v,r?.overlay?.gradient?.fromColor,a?.overlay?.gradient?.fromColor),toColor:p(v,r?.overlay?.gradient?.toColor,a?.overlay?.gradient?.toColor)}},visible:r?.visible??a?.visible??!1}}),o=i(()=>t.value?.overlay),l=i(()=>t.value?.visible);return d({overlay:o,visible:l})}function ge(e){const n=c(),t=i(()=>{const l=n.design.value[e],r=n.defaults.value[e];return{enabled:l?.enabled??r?.enabled}}),o=i(()=>t.value?.enabled);return d({enabled:o})}function pe(e){const n=c(),t=i(()=>{const l=n.design.value[e],r=n.defaults.value[e];return{value:l?.value??r?.value}}),o=i(()=>t.value?.value);return d({value:o})}function be(e){const n=c(),t=i(()=>{const l=n.design.value[e],r=n.defaults.value[e],a=n.globalDesign.value;return{background:{type:l?.background?.type??r?.background?.type,solid:{color:p(a,l?.background?.solid?.color,r?.background?.solid?.color)},gradient:{fromColor:p(a,l?.background?.gradient?.fromColor,r?.background?.gradient?.fromColor),toColor:p(a,l?.background?.gradient?.toColor,r?.background?.gradient?.toColor)}}}}),o=i(()=>t.value?.background);return d({background:o})}function Ee(){const e=c(),n=i(()=>e.design.value.layout),t=i(()=>n.value);return d({layout:t})}function me(){const e=c();return i(()=>{const n=e.design.value.logo,t=e.defaults.value.logo,o=e.globalDesign.value;return{font:I(o,n?.font,t?.font),size:y(o,n?.size,t?.size),bold:n?.bold??t?.bold,italic:n?.italic??t?.italic,color:p(o,n?.color,t?.color),visible:n?.visible??t?.visible??!1,spacing:n?.spacing??t?.spacing??0,capitalization:n?.capitalization??t?.capitalization??"none",frame:se(o,n?.frame,t?.frame)}})}function z(e){return{app:U(e)}}function Te(e,n){return{init:()=>{const{app:t}=z(e);return n?.init?.(t),{render:async(o,l)=>(c().init(t,o,l.content,l.design,l.defaults,l.externalContent,o.globalDesign),n?.render?.(t,o,l),{html:await K(t,{context:o}),state:{context:o,data:l}})}}}}function Oe(e,n){return{init:()=>{const{app:t}=z(e);return n?.init?.(t),{mount:(o,l)=>{c().init(t,l.context,l.data.content,l.data.design,l.data.defaults,l.data.externalContent,l.context.globalDesign),n?.mount?.(t,o,l),t.mount(o)},update:o=>{c().update(t,o.data.content,o.data.design,o.data.defaults,o.data.externalContent,o.context.globalDesign),n?.update?.(t,o)},unmount:()=>{n?.unmount?.(t),t.unmount()}}}}}function Ie(){return globalThis.window.instantsite}const _e={PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER"},we={CATEGORY_TITLE:"MAIN_TITLE",PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER"},ye={TOP_BAR:"TOP_BAR",GALLERY:"GALLERY",SIDEBAR:"SIDEBAR",DESCRIPTION:"DESCRIPTION",REVIEW_LIST:"REVIEW_LIST",RELATED_PRODUCTS:"RELATED_PRODUCTS",BOTTOM_BAR:"FOOTER"};export{_e as CatalogLayoutSlot,we as CategoryLayoutSlot,k as EditorTypes,ye as ProductLayoutSlot,Oe as createVueClientApp,Te as createVueServerApp,be as useBackgroundElementDesign,h as useButtonElementContent,de as useButtonElementDesign,le as useDeckElementContent,D as useImageElementContent,fe as useImageElementDesign,R as useInputboxElementContent,Ie as useInstantsiteJsApi,Ee as useLayoutElementDesign,ue as useLogoElementContent,me as useLogoElementDesign,x as useMenuElementContent,oe as useNavigationMenuElementContent,S as useSelectboxElementContent,pe as useSelectboxElementDesign,ce as useTextElementDesign,C as useTextareaElementContent,ve as useTextareaElementDesign,A as useToggleElementContent,ge as useToggleElementDesign,c as useVueBaseProps};
1
+ import{getCurrentInstance as P,ref as b,computed as i,reactive as d,createSSRApp as U}from"vue";import{renderToString as K}from"vue/server-renderer";const C=new Map;function c(){const e=(l,r,a,v,g,s,u)=>{C.set(l._uid,{context:b(r),content:b(a),design:b(v),defaults:b(g),site:b(s?.site??{}),category:b(s?.category),globalDesign:b(u)})},n=(l,r,a,v,g,s)=>{const u=C.get(l._uid);u!==void 0&&(u.content.value=r,u.design.value=a,u.defaults.value=v,u.site.value=g.site??{},u.category.value=g.category,u.globalDesign.value=s)},t=P()?.appContext.app._uid??-1,o=C.get(t);return{init:e,update:n,context:o?.context,content:o?.content,design:o?.design,defaults:o?.defaults,site:o?.site,category:o?.category,globalDesign:o?.globalDesign}}function w(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return F(o,e)}function F(e,n){const t=i(()=>{const r=e.value[n];if(r!==void 0){if(typeof r=="string")return r;throw new Error(`Element ${n} is not inputbox`)}}),o=i(()=>t.value!==void 0),l=i(()=>t.value);return d({hasContent:o,value:l})}function y(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return W(o,e)}function W(e,n){const t=i(()=>{const r=e.value[n];if(r!==void 0){if(typeof r=="string")return r;throw new Error(`Element ${n} is not textarea`)}}),o=i(()=>t.value!==void 0),l=i(()=>t.value);return d({hasContent:o,value:l})}const T={HYPER_LINK:"HYPER_LINK",SCROLL_TO_TILE:"SCROLL_TO_TILE",MAIL_LINK:"MAIL_LINK",TEL_LINK:"TEL_LINK",GO_TO_STORE:"GO_TO_STORE",GO_TO_STORE_LINK:"GO_TO_STORE_LINK",GO_TO_PAGE:"GO_TO_PAGE",GO_TO_CATEGORY:"GO_TO_CATEGORY"};function X(e){if("tileId"in e)return e.tileId;if("tileIdForScroll"in e)return e.tileIdForScroll}function Y(e){if("pageId"in e)return e.pageId;if("pageIdForNavigate"in e)return e.pageIdForNavigate}function V(e){if("pageUrl"in e)return e.pageUrl;switch(Y(e)){case"products":return"/products";case"cart":return"/cart";case"account":return"/account";case"search":return"/search";case"home":default:return"/"}}const R=(e,n)=>{if(!e||n)return;const{type:t,link:o,email:l,phone:r}=e,a=V(e);switch(t){case T.HYPER_LINK:if(o)return()=>window.open(o,"_blank");break;case T.GO_TO_STORE:case T.GO_TO_STORE_LINK:return()=>window.open("/products","_self");case T.MAIL_LINK:if(l)return()=>window.open(`mailto:${l}`,"_self");break;case T.TEL_LINK:if(r)return()=>window.open(`tel:${r}`,"_self");break;case T.SCROLL_TO_TILE:if(typeof document<"u")return()=>{const v=X(e);document.getElementById(`tile-${v}`)?.scrollIntoView()};break;case T.GO_TO_PAGE:if(a)return()=>window.open(a,"_self");break;default:console.error(`Unknown type of ActionLink: ${t}`)}};function H(e){return"title"in e&&"type"in e}function j(e,n,t){const o=i(()=>{const I=e.value[n];if(I!==void 0){if(H(I))return I;throw new Error(`Element ${n} is not action link`)}}),l=i(()=>o.value?.title),r=i(()=>o.value?.type),a=i(()=>o.value?.link),v=i(()=>o.value?.email),g=i(()=>o.value?.phone),s=i(()=>o.value?.tileId?`tile-${o.value?.tileId}`:null),u=i(()=>o.value?.type==="GO_TO_STORE_LINK"?"products":o.value?.pageId),f=i(()=>o.value?.pageUrl),E=i(()=>!!l.value),z=i(()=>!!a.value),$=R(o.value,t);return d({title:l,type:r,link:a,email:v,phone:g,tileDivId:s,pageId:u,pageUrl:f,hasTitle:E,hasLink:z,performAction:$})}function S(e,n){const t=c(),o=i(()=>!!t.site?.value?.isPreviewMode),l=i(()=>n!==void 0?n:t.content.value!==void 0?t.content.value:{});return j(l,e,o.value)}function J(e){return"bucket"in e&&"borderInfo"in e&&"set"in e}function m(e,n){const t=new RegExp(/^https?:\/\//);return e!=null&&t.test(e)?e:`${n}/${e}`}function h(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return q(o,e)}function q(e,n){const t=i(()=>{const s=e.value[n];if(s!==void 0){if(J(s))return s;throw new Error(`Element ${n} is not image`)}}),o=i(()=>t.value===void 0?"":c().context.value.imageBuckets?.[t.value?.bucket]),l=i(()=>t.value!==void 0),r=i(()=>m(t.value?.set?.["cropped-webp-100x200"]?.url,o.value)),a=i(()=>m(t.value?.set?.["cropped-webp-1000x2000"]?.url,o.value)),v=i(()=>m(t.value?.set?.["webp-200x200"]?.url,o.value)),g=i(()=>m(t.value?.set?.["webp-2000x2000"]?.url,o.value));return d({hasContent:l,lowResolutionMobileImage:r,highResolutionMobileImage:a,lowResolutionDesktopImage:v,highResolutionDesktopImage:g})}function Q(e){return"enabled"in e}function D(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return Z(o,e)}function Z(e,n){const t=i(()=>{const r=e.value[n];if(r!==void 0){if(Q(r))return r;throw new Error(`Element ${n} is not toggle`)}}),o=i(()=>t.value!==void 0),l=i(()=>t.value?.enabled);return d({hasContent:o,value:l})}function A(e,n){const t=c(),o=i(()=>n!==void 0?n:t.content.value);return ee(o,e)}function ee(e,n){const t=i(()=>{const r=e.value[n];if(r!==void 0){if(typeof r=="string")return r;throw new Error(`Element ${n} is not selectbox`)}}),o=i(()=>t.value!==void 0),l=i(()=>t.value);return d({hasContent:o,value:l})}function te(e){return e!==null&&"items"in e}function x(e){const n=c(),t=i(()=>{const a=n.content.value[e];if(a!==void 0){if(te(a))return a;throw new Error(`Element ${e} is not an menu`)}}),o=i(()=>!!n.site?.value?.isPreviewMode),l=i(()=>t.value!==void 0),r=i(()=>t.value?.items?t.value.items.map(a=>({...a,performAction:R(a,o.value)})):[]);return d({hasContent:l,items:r})}const ne="menu";function oe(){return x(ne)}var k=(e=>(e.INPUTBOX="INPUTBOX",e.TEXTAREA="TEXTAREA",e.BUTTON="BUTTON",e.IMAGE="IMAGE",e.TOGGLE="TOGGLE",e.SELECTBOX="SELECTBOX",e))(k||{});function ie(e){if(typeof e!="object"||e===null)return!1;const n=e;return Array.isArray(n.cards)&&n.cards.every(t=>typeof t.settings=="object"&&t.settings!==null)}function le(e){const n=c(),t=i(()=>{const r=n.content.value[e];if(r!==void 0){if(ie(r))return r;throw new Error(`Element ${e} is not of DECK type`)}}),o=i(()=>t.value!==void 0&&t.value.cards.length>0),l=i(()=>t.value?.cards);return d({hasContent:o,cards:l,getReactiveRef:re})}function re(e,n,t){if(e==null)throw Error("Could not get a reactive ref for undefined Card");const o=e.settings[t];if(o===void 0)return o;switch(n){case"TEXTAREA":return y(t,e.settings);case"INPUTBOX":return w(t,e.settings);case"SELECTBOX":return A(t,e.settings);case"IMAGE":return h(t,e.settings);case"TOGGLE":return D(t,e.settings);case"BUTTON":return S(t,e.settings);default:return}}function ae(e){return"type"in e&&("text"in e||"image"in e)}function O(e,n){const t=new RegExp(/^https?:\/\//);return e!==void 0&&t.test(e)?e:`${n}/${e}`}function ue(){const e=c(),n=i(()=>{const a=e.content.value.logo;if(a!==void 0){if(ae(a))return a;throw new Error("Element logo is not LOGO")}}),t=i(()=>n.value?.type),o=i(()=>n.value?.text),l=i(()=>n.value?.image===void 0?"":e.context.value.imageBuckets?.[n.value.image.bucket]),r=i(()=>({lowResolutionMobileImage:O(n.value?.image?.set?.["cropped-webp-100x200"]?.url,l.value),highResolutionMobileImage:O(n.value?.image?.set?.["cropped-webp-1000x2000"]?.url,l.value),lowResolutionDesktopImage:O(n.value?.image?.set?.["webp-200x200"]?.url,l.value),highResolutionDesktopImage:O(n.value?.image?.set?.["webp-2000x2000"]?.url,l.value)}));return d({type:t,text:o,image:r})}function G(e,n){if(n===void 0)return;if(!n.startsWith("global."))return n.replaceAll("_"," ");const t=n.split(".").at(2);if(t!==void 0)return e.fontFamily?e.fontFamily[t].replaceAll("_"," "):void 0}function _(e,n,t){return n?G(e,n):G(e,t)}function N(e,n){if(n===void 0)return;if(typeof n!="string"||!n.startsWith("global."))return n;const t=n.split(".").at(2);if(t!==void 0)return e.textSize?e.textSize[t]:void 0}function L(e,n,t){return n?N(e,n):N(e,t)}function B(e,n){if(n===void 0)return;if(typeof n!="string"||!n.startsWith("global."))return n;const t=n.split(".").at(2);if(t!==void 0)return e.color?e.color[t]:void 0}function p(e,n,t){return n?B(e,n):B(e,t)}function se(e,n,t){return{visible:n?.visible??t?.visible??!1,width:n?.width??t?.width??1,color:p(e,n?.color,t?.color)}}function ce(e){const n=c(),t=i(()=>{const s=n.design.value[e],u=n.defaults.value[e],f=n.globalDesign.value;return{font:_(f,s?.font,u?.font),size:L(f,s?.size,u?.size),bold:s?.bold??u?.bold,italic:s?.italic??u?.italic,color:p(f,s?.color,u?.color),visible:s?.visible??u?.visible??!1}}),o=i(()=>t.value?.font),l=i(()=>t.value?.size),r=i(()=>t.value?.bold),a=i(()=>t.value?.italic),v=i(()=>t.value?.color),g=i(()=>t.value?.visible);return d({font:o,size:l,bold:r,italic:a,color:v,visible:g})}function ve(e){const n=c(),t=i(()=>{const u=n.design.value[e],f=n.defaults.value[e],E=n.globalDesign.value;return{font:_(E,u?.font,f?.font),size:L(E,u?.size,f?.size),bold:u?.bold??f?.bold,italic:u?.italic??f?.italic,color:p(E,u?.color,f?.color),visible:u?.visible??f?.visible??!1,whiteSpace:"pre-wrap"}}),o=i(()=>t.value?.font),l=i(()=>t.value?.size),r=i(()=>t.value?.bold),a=i(()=>t.value?.italic),v=i(()=>t.value?.color),g=i(()=>t.value?.visible),s=i(()=>t.value?.whiteSpace);return d({font:o,size:l,bold:r,italic:a,color:v,visible:g,whiteSpace:s})}function de(e){const n=c(),t=i(()=>{const s=n.design.value[e],u=n.defaults.value[e],f=n.globalDesign.value;return{appearance:s?.appearance??u?.appearance,font:_(f,s?.font,u?.font),size:s?.size??u?.size,style:s?.style??u?.style,color:p(f,s?.color,u?.color),visible:s?.visible??u?.visible??!1}}),o=i(()=>t.value?.appearance),l=i(()=>t.value?.font),r=i(()=>t.value?.size),a=i(()=>t.value?.style),v=i(()=>t.value?.color),g=i(()=>t.value?.visible);return d({appearance:o,font:l,size:r,style:a,color:v,visible:g})}function fe(e){const n=c(),t=i(()=>{const r=n.design.value[e],a=n.defaults.value[e],v=n.globalDesign.value;return{overlay:{type:r?.overlay?.type??a?.overlay?.type,solid:{color:p(v,r?.overlay?.solid?.color,a?.overlay?.solid?.color)},gradient:{fromColor:p(v,r?.overlay?.gradient?.fromColor,a?.overlay?.gradient?.fromColor),toColor:p(v,r?.overlay?.gradient?.toColor,a?.overlay?.gradient?.toColor)}},visible:r?.visible??a?.visible??!1}}),o=i(()=>t.value?.overlay),l=i(()=>t.value?.visible);return d({overlay:o,visible:l})}function ge(e){const n=c(),t=i(()=>{const l=n.design.value[e],r=n.defaults.value[e];return{enabled:l?.enabled??r?.enabled}}),o=i(()=>t.value?.enabled);return d({enabled:o})}function pe(e){const n=c(),t=i(()=>{const l=n.design.value[e],r=n.defaults.value[e];return{value:l?.value??r?.value}}),o=i(()=>t.value?.value);return d({value:o})}function be(e){const n=c(),t=i(()=>{const l=n.design.value[e],r=n.defaults.value[e],a=n.globalDesign.value;return{background:{type:l?.background?.type??r?.background?.type,solid:{color:p(a,l?.background?.solid?.color,r?.background?.solid?.color)},gradient:{fromColor:p(a,l?.background?.gradient?.fromColor,r?.background?.gradient?.fromColor),toColor:p(a,l?.background?.gradient?.toColor,r?.background?.gradient?.toColor)}}}}),o=i(()=>t.value?.background);return d({background:o})}function Te(){const e=c(),n=i(()=>e.design.value.layout),t=i(()=>n.value);return d({layout:t})}function Ee(){const e=c();return i(()=>{const n=e.design.value.logo,t=e.defaults.value.logo,o=e.globalDesign.value;return{font:_(o,n?.font,t?.font),size:L(o,n?.size,t?.size),bold:n?.bold??t?.bold,italic:n?.italic??t?.italic,color:p(o,n?.color,t?.color),visible:n?.visible??t?.visible??!1,spacing:n?.spacing??t?.spacing??0,capitalization:n?.capitalization??t?.capitalization??"none",frame:se(o,n?.frame,t?.frame)}})}function M(e){return{app:U(e)}}function me(e,n){return{init:()=>{const{app:t}=M(e);return n?.init?.(t),{render:async(o,l)=>(c().init(t,o,l.content,l.design,l.defaults,l.externalContent,o.globalDesign),n?.render?.(t,o,l),{html:await K(t,{context:o}),state:{context:o,data:l}})}}}}function Oe(e,n){return{init:()=>{const{app:t}=M(e);return n?.init?.(t),{mount:(o,l)=>{c().init(t,l.context,l.data.content,l.data.design,l.data.defaults,l.data.externalContent,l.context.globalDesign),n?.mount?.(t,o,l),t.mount(o)},update:o=>{c().update(t,o.data.content,o.data.design,o.data.defaults,o.data.externalContent,o.context.globalDesign),n?.update?.(t,o)},unmount:()=>{n?.unmount?.(t),t.unmount()}}}}}function _e(){return globalThis.window.instantsite}const Ie={PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},Ce={CATEGORY_TITLE:"MAIN_TITLE",PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},Le={TOP_BAR:"TOP_BAR",GALLERY:"GALLERY",SIDEBAR:"SIDEBAR",DESCRIPTION:"DESCRIPTION",REVIEW_LIST:"REVIEW_LIST",RELATED_PRODUCTS:"RELATED_PRODUCTS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"};export{Ie as CatalogLayoutSlot,Ce as CategoryLayoutSlot,k as EditorTypes,Le as ProductLayoutSlot,Oe as createVueClientApp,me as createVueServerApp,be as useBackgroundElementDesign,S as useButtonElementContent,de as useButtonElementDesign,le as useDeckElementContent,h as useImageElementContent,fe as useImageElementDesign,w as useInputboxElementContent,_e as useInstantsiteJsApi,Te as useLayoutElementDesign,ue as useLogoElementContent,Ee as useLogoElementDesign,x as useMenuElementContent,oe as useNavigationMenuElementContent,A as useSelectboxElementContent,pe as useSelectboxElementDesign,ce as useTextElementDesign,y as useTextareaElementContent,ve as useTextareaElementDesign,D as useToggleElementContent,ge as useToggleElementDesign,c as useVueBaseProps};