@lightspeed/crane-api 1.1.1 → 2.1.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.
- package/CHANGELOG.md +36 -0
- package/dist/index.d.mts +12513 -428
- package/dist/index.d.ts +12514 -428
- package/dist/index.mjs +1 -1
- package/package.json +4 -1
- package/types.d.ts +26 -11
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSSRApp as le,getCurrentInstance as ue,ref as m,computed as o,reactive as T}from"vue";import{renderToString as se}from"vue/server-renderer";function y(e){return{app:le(e)}}const b=new Map;function d(){const e=(r,i,l,c,v,s,u)=>{b.set(r._uid,{context:m(i),content:m(l),design:m(c),defaults:m(v),site:m(s?.site??{}),category:m(s?.category),storeData:m(s?.storeData),globalDesign:m(u)})},t=(r,i,l,c,v,s)=>{const u=b.get(r._uid);u!==void 0&&(u.content.value=i,u.design.value=l,u.defaults.value=c,u.site.value=v.site??{},u.category.value=v.category,u.globalDesign.value=s,u.storeData.value=v.storeData)},n=ue()?.appContext.app._uid??-1,a=b.get(n);return{init:e,update:t,context:a?.context,content:a?.content,design:a?.design,defaults:a?.defaults,site:a?.site,category:a?.category,storeData:a?.storeData,globalDesign:a?.globalDesign}}function ce(e,t){return{init:()=>{const{app:n}=y(e);return t?.init?.(n),{mount:(a,r)=>{d().init(n,r.context,r.data.content,r.data.design,r.data.defaults,r.data.externalContent,r.context.globalDesign),t?.mount?.(n,a,r),n.mount(a)},update:a=>{d().update(n,a.data.content,a.data.design,a.data.defaults,a.data.externalContent,a.context.globalDesign),t?.update?.(n,a)},unmount:()=>{t?.unmount?.(n),n.unmount()}}}}}function ve(){return globalThis.window.instantsite}function de(e,t){return{init:()=>{const{app:n}=y(e);return t?.init?.(n),{render:async(a,r)=>(d().init(n,a,r.content,r.design,r.defaults,r.externalContent,a.globalDesign),t?.render?.(n,a,r),{html:await se(n,{context:a}),state:{context:a,data:r}})}}}}var D=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(D||{}),G=(e=>(e.COLOR="COLOR",e.GRADIENT="GRADIENT",e.NONE="NONE",e))(G||{}),N=(e=>(e.SOLID="SOLID",e.OUTLINE="OUTLINE",e.TEXT="TEXT",e))(N||{}),h=(e=>(e.SMALL="SMALL",e.MEDIUM="MEDIUM",e.LARGE="LARGE",e))(h||{}),w=(e=>(e.ROUND_CORNER="ROUND_CORNER",e.RECTANGLE="RECTANGLE",e.PILL="PILL",e))(w||{}),M=(e=>(e.COLOR="COLOR",e.GRADIENT="GRADIENT",e))(M||{}),U=(e=>(e.SECTION="SECTION",e.HEADER="HEADER",e.FOOTER="FOOTER",e))(U||{}),P=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e[e.Layout=3]="Layout",e[e.Asset=4]="Asset",e[e.SharedFiles=5]="SharedFiles",e))(P||{}),B=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.PageTemplateDescriptor=6]="PageTemplateDescriptor",e[e.TemplateAsset=7]="TemplateAsset",e[e.Layout=8]="Layout",e[e.LayoutSettings=9]="LayoutSettings",e[e.LayoutAsset=10]="LayoutAsset",e[e.SlotServer=11]="SlotServer",e[e.SlotClient=12]="SlotClient",e[e.SharedTranslation=13]="SharedTranslation",e))(B||{}),x=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE="GO_TO_STORE",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(x||{}),Ee=(e=>(e.TEXTAREA="TEXTAREA",e.INPUTBOX="INPUTBOX",e.SELECTBOX="SELECTBOX",e.IMAGE="IMAGE",e.TOGGLE="TOGGLE",e.BUTTON="BUTTON",e.DECK="DECK",e.MENU="MENU",e.NAVIGATION_MENU="NAVIGATION_MENU",e.LOGO="LOGO",e.INFO="INFO",e.DIVIDER="DIVIDER",e.CATEGORY_SELECTOR="CATEGORY_SELECTOR",e.PRODUCT_SELECTOR="PRODUCT_SELECTOR",e))(Ee||{}),k=(e=>(e.TEXT="TEXT",e.BUTTON="BUTTON",e.IMAGE="IMAGE",e.TOGGLE="TOGGLE",e.SELECTBOX="SELECTBOX",e.BACKGROUND="BACKGROUND",e.COLOR_PICKER="COLOR_PICKER",e.LOGO="LOGO",e.DIVIDER="DIVIDER",e))(k||{}),K=(e=>(e.PRODUCT="PRODUCT",e.CATALOG="CATALOG",e.CATEGORY="CATEGORY",e.HOME="HOME",e.CUSTOM="CUSTOM",e))(K||{}),$=(e=>(e.HOME="home",e.CATALOG="catalog",e.CATEGORY="category",e.PRODUCT="product",e))($||{}),Y=(e=>(e.CONTENT="Content",e.DESIGN="Design",e))(Y||{}),z=(e=>(e.ORIGINAL="original",e.WEBP_LOW_RES="webp-200x200",e.WEBP_HI_2X_RES="webp-2000x2000",e.MOBILE_WEBP_LOW_RES="cropped-webp-100x200",e.MOBILE_WEBP_HI_RES="cropped-webp-1000x2000",e))(z||{}),X=(e=>(e.TILE_LOADED="tile-loaded",e.TILE_UNLOADED="tile-unloaded",e))(X||{});const Te={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"},ge={PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},fe={CATEGORY_TITLE:"MAIN_TITLE",PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},Oe={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"},O={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",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"};function pe(e){if("tileId"in e)return e.tileId;if("tileIdForScroll"in e)return e.tileIdForScroll}function me(e){if("pageId"in e)return e.pageId;if("pageIdForNavigate"in e)return e.pageIdForNavigate}function Le(e){if("pageUrl"in e)return e.pageUrl;switch(me(e)){case"products":return"/products";case"cart":return"/cart";case"account":return"/account";case"search":return"/search";case"home":default:return"/"}}function _e(e){if("categoryId"in e)return e.categoryId}const F=(e,t,n)=>{if(!e||t)return;const{type:a,link:r,email:i,phone:l}=e,c=Le(e),v=_e(e);switch(a){case O.HYPER_LINK:if(r)return()=>window.open(r,"_blank");break;case O.GO_TO_STORE:case O.GO_TO_STORE_LINK:return()=>window.open("/products","_self");case O.GO_TO_CATEGORY:case O.GO_TO_CATEGORY_LINK:const s=n?.find(u=>u.id===v)?.url;return s===void 0?()=>window.open("/404","_self"):()=>window.open(s,"_self");case O.MAIL_LINK:if(i)return()=>window.open(`mailto:${i}`,"_self");break;case O.TEL_LINK:if(l)return()=>window.open(`tel:${l}`,"_self");break;case O.SCROLL_TO_TILE:if(typeof document<"u")return()=>{const u=pe(e);document.getElementById(`tile-${u}`)?.scrollIntoView()};break;case O.GO_TO_PAGE:if(c)return()=>window.open(c,"_self");break;default:console.error(`Unknown type of ActionLink: ${a}`)}};function Ie(e){return"title"in e&&"type"in e}function Ce(e,t,n,a){const r=o(()=>{const _=e.value[t];if(_!==void 0){if(Ie(_))return _;throw new Error(`Element ${t} is not action link`)}}),i=o(()=>r.value?.title),l=o(()=>r.value?.type),c=o(()=>r.value?.link),v=o(()=>r.value?.email),s=o(()=>r.value?.phone),u=o(()=>r.value?.tileId?`tile-${r.value?.tileId}`:null),E=o(()=>r.value?.type==="GO_TO_STORE_LINK"?"products":r.value?.pageId),g=o(()=>r.value?.pageUrl),I=o(()=>!!i.value),p=o(()=>!!c.value),L=F(r.value,n,a);return T({title:i,type:l,link:c,email:v,phone:s,tileDivId:u,pageId:E,pageUrl:g,hasTitle:I,hasLink:p,performAction:L})}function W(e,t){const n=d(),a=o(()=>!!n.site?.value?.isPreviewMode),r=o(()=>n.category?.value?.categories??[]),i=o(()=>t!==void 0?t:n.content.value!==void 0?n.content.value:{});return Ce(i,e,a.value,r.value)}function H({content:e,elementName:t,errorMessage:n,validatorFn:a}){return o(()=>{const r=e.value?.[t];if(r!==void 0){if(a(r))return r;throw new Error(n)}})}function Re(e){return typeof e=="object"&&e!==null&&"categories"in e}function Se(e){return o(()=>e.value.reduce((t,n)=>(t[n.id]=n,t),{}))}function be(e){return e!==void 0}function Ae(e){return!!e?.trim()}function ye({name:e,customName:t,selectionType:n}){return n==="ROOT"?e:Ae(t)?t:e}function De(e,t){return be(e)&&t}function V({itemId:e,id:t,alt:n,name:a,nameTranslated:r,customName:i,enabled:l,productsCount:c,url:v,imageUrl:s,thumbnailImageUrl:u,imageBorderInfo:E,selectionType:g}){return{itemId:e||t.toString(),id:t,alt:n,name:ye({name:a,customName:i,selectionType:g}),nameTranslated:r,label:a,enabled:l,url:v,productsCount:c,imageUrl:s,thumbnailImageUrl:u,imageBorderInfo:E,showCategory:De(t,l)}}function j(e,t,n){const a=d(),r=o(()=>t!==void 0?t:a.content.value),i=H({content:r,elementName:e,errorMessage:`Element ${e} is not a category selector type`,validatorFn:Re}),l=o(()=>n??a.storeData?.value),c=o(()=>i.value?.categories.selectionType??"ROOT"),v=o(()=>l.value?.categories??[]),s=o(()=>i.value?.categories?.categoryIds??[]),u=o(()=>{const I=Se(v);return c.value==="MANUAL"?i.value?.categories?.items?.map(p=>{const L=I.value[p.id];return V({...p,...L,selectionType:c.value})})??[]:l?.value?.categories.map(p=>V({...p,selectionType:c.value}))??[]}),E=o(()=>i.value!==void 0),g=o(()=>u.value!==void 0&&u.value.length>0);return T({categories:u,categoryIds:s,hasContent:E,hasCategories:g})}function Ge(e){return typeof e=="object"&&e!==null&&("products"in e||"product"in e)}function J(e,t,n){const a=d(),r=o(()=>t!==void 0?t:a.content.value),i=H({content:r,elementName:e,errorMessage:`Element ${e} is not a product selector type`,validatorFn:Ge}),l=o(()=>n??a.storeData?.value),c=o(()=>i.value?.products?.selectionType??"MANUAL"),v=o(()=>i.value?.products?.productIds??[]),s=o(()=>i.value?.product?.id),u=o(()=>i.value?.categoryId?parseInt(i.value.categoryId,10):void 0),E=o(()=>{if(v.value&&u.value&&c.value==="CATEGORY")return l?.value?.products.filter(_=>_?.defaultCategoryId===u.value)??[];if(typeof u.value=="number"&&u.value===0&&c.value==="CATEGORY")return l?.value?.products??[];const L=s.value?[s.value]:v.value??[];return l?.value?.products?.filter(_=>L.includes(_.id))??[]}),g=o(()=>l?.value?.categories.filter(L=>L.id===u?.value)??[]),I=o(()=>i.value!==void 0&&E.value.length>0),p=o(()=>E.value!==void 0&&E.value.length>0);return T({products:E,categories:g,categoryId:u,hasContent:I,hasProducts:p})}function Ne(e){return"bucket"in e&&"borderInfo"in e&&"set"in e}function C(e,t){const n=new RegExp(/^https?:\/\//);return e!=null&&n.test(e)?e:`${t}/${e}`}function he(e,t){const n=o(()=>{const s=e.value[t];if(s!==void 0){if(Ne(s))return s;throw new Error(`Element ${t} is not image`)}}),a=o(()=>n.value===void 0?"":d().context.value.imageBuckets?.[n.value?.bucket]),r=o(()=>n.value!==void 0),i=o(()=>C(n.value?.set?.["cropped-webp-100x200"]?.url,a.value)),l=o(()=>C(n.value?.set?.["cropped-webp-1000x2000"]?.url,a.value)),c=o(()=>C(n.value?.set?.["webp-200x200"]?.url,a.value)),v=o(()=>C(n.value?.set?.["webp-2000x2000"]?.url,a.value));return T({hasContent:r,lowResolutionMobileImage:i,highResolutionMobileImage:l,lowResolutionDesktopImage:c,highResolutionDesktopImage:v})}function q(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return he(a,e)}function we(e,t){const n=o(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not inputbox`)}}),a=o(()=>n.value!==void 0&&n.value.length>0),r=o(()=>n.value);return T({hasContent:a,value:r})}function Q(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return we(a,e)}function Me(e,t){const n=o(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not selectbox`)}}),a=o(()=>n.value!==void 0),r=o(()=>n.value);return T({hasContent:a,value:r})}function Z(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return Me(a,e)}function Ue(e,t){const n=o(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not textarea`)}}),a=o(()=>n.value!==void 0),r=o(()=>n.value);return T({hasContent:a,value:r})}function ee(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return Ue(a,e)}function Pe(e){return"enabled"in e}function Be(e,t){const n=o(()=>{const i=e.value[t];if(i!==void 0){if(Pe(i))return i;throw new Error(`Element ${t} is not toggle`)}}),a=o(()=>n.value!==void 0),r=o(()=>n.value?.enabled);return T({hasContent:a,value:r})}function te(e,t){const n=d(),a=o(()=>t!==void 0?t:n.content.value);return Be(a,e)}var ne=(e=>(e.INPUTBOX="INPUTBOX",e.TEXTAREA="TEXTAREA",e.BUTTON="BUTTON",e.IMAGE="IMAGE",e.TOGGLE="TOGGLE",e.SELECTBOX="SELECTBOX",e.CATEGORY_SELECTOR="CATEGORY_SELECTOR",e.PRODUCT_SELECTOR="PRODUCT_SELECTOR",e))(ne||{});function xe(e){if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.cards)&&t.cards.every(n=>typeof n.settings=="object"&&n.settings!==null)}function ke(e,t,n,a){if(e==null)throw Error("Could not get a reactive ref for undefined Card");const r=e.settings[n];if(r===void 0)return r;switch(t){case"TEXTAREA":return ee(n,e.settings);case"INPUTBOX":return Q(n,e.settings);case"SELECTBOX":return Z(n,e.settings);case"IMAGE":return q(n,e.settings);case"TOGGLE":return te(n,e.settings);case"BUTTON":return W(n,e.settings);case"CATEGORY_SELECTOR":return j(n,e.settings,a);case"PRODUCT_SELECTOR":return J(n,e.settings,a);default:return}}function Ke(e){const t=d(),n=o(()=>t.storeData?.value),a=o(()=>{const l=t.content.value[e];if(l!==void 0){if(xe(l))return l;throw new Error(`Element ${e} is not of DECK type`)}}),r=o(()=>a.value!==void 0&&a.value.cards.length>0),i=o(()=>a.value?.cards);return T({hasContent:r,cards:i,getReactiveRef:(l,c,v)=>ke(l,c,v,n.value)})}function $e(e){return"type"in e&&("text"in e||"image"in e)}function R(e,t){const n=new RegExp(/^https?:\/\//);return e!==void 0&&n.test(e)?e:`${t}/${e}`}function Ye(){const e=d(),t=o(()=>{const l=e.content.value.logo;if(l!==void 0){if($e(l))return l;throw new Error("Element logo is not LOGO")}}),n=o(()=>t.value?.type),a=o(()=>t.value?.text),r=o(()=>t.value?.image===void 0?"":e.context.value.imageBuckets?.[t.value.image.bucket]),i=o(()=>({lowResolutionMobileImage:R(t.value?.image?.set?.["cropped-webp-100x200"]?.url,r.value),highResolutionMobileImage:R(t.value?.image?.set?.["cropped-webp-1000x2000"]?.url,r.value),lowResolutionDesktopImage:R(t.value?.image?.set?.["webp-200x200"]?.url,r.value),highResolutionDesktopImage:R(t.value?.image?.set?.["webp-2000x2000"]?.url,r.value)}));return T({type:n,text:a,image:i})}function ze(e){return e!==null&&"items"in e}function oe(e){const t=d(),n=o(()=>{const l=t.content.value[e];if(l!==void 0){if(ze(l))return l;throw new Error(`Element ${e} is not an menu`)}}),a=o(()=>!!t.site?.value?.isPreviewMode),r=o(()=>n.value!==void 0),i=o(()=>n.value?.items?n.value.items.map(l=>({...l,performAction:F(l,a.value)})):[]);return T({hasContent:r,items:i})}const Xe="menu";function Fe(){return oe(Xe)}function We(){return globalThis.craneSharedTranslation??{}}function He(){const e=d(),t=o(()=>e.site?.value),n=o(()=>We()),a=o(()=>{const r=t.value?.languages;return r?r.find(i=>i.selected)?.code??r.find(i=>i.main)?.code??"en":"en"});return{t:r=>{const i=n.value;if(!i||Object.keys(i).length===0)return r;const l=a.value,c=i[l]?.[r];if(c!==void 0)return c;if(l!=="en"){const v=i.en?.[r];if(v!==void 0)return v}return r},currentLanguageCode:a}}function ae(e,t){if(t===void 0)return;if(!t.startsWith("global."))return t.replaceAll("_"," ");const n=t.split(".").at(2);if(n!==void 0)return e.fontFamily?e.fontFamily[n].replaceAll("_"," "):void 0}function S(e,t,n){return t?ae(e,t):ae(e,n)}function re(e,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const n=t.split(".").at(2);if(n!==void 0)return e.textSize?e.textSize[n]:void 0}function A(e,t,n){return t?re(e,t):re(e,n)}function ie(e,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const n=t.split(".").at(2);if(n!==void 0)return e.color?e.color[n]:void 0}function f(e,t,n){return t?ie(e,t):ie(e,n)}function Ve(e,t,n){return{visible:t?.visible??n?.visible??!1,width:t?.width??n?.width??1,color:f(e,t?.color,n?.color)}}function je(e){const t=d(),n=o(()=>{const r=t.design.value[e],i=t.defaults.value[e],l=t.globalDesign.value;return{background:{type:r?.background?.type??i?.background?.type,solid:{color:f(l,r?.background?.solid?.color,i?.background?.solid?.color)},gradient:{fromColor:f(l,r?.background?.gradient?.fromColor,i?.background?.gradient?.fromColor),toColor:f(l,r?.background?.gradient?.toColor,i?.background?.gradient?.toColor)}}}}),a=o(()=>n.value?.background);return T({background:a})}function Je(e){const t=d(),n=o(()=>{const s=t.design.value[e],u=t.defaults.value[e],E=t.globalDesign.value;return{appearance:s?.appearance??u?.appearance,font:S(E,s?.font,u?.font),size:s?.size??u?.size,style:s?.style??u?.style,color:f(E,s?.color,u?.color),visible:s?.visible??u?.visible??!1}}),a=o(()=>n.value?.appearance),r=o(()=>n.value?.font),i=o(()=>n.value?.size),l=o(()=>n.value?.style),c=o(()=>n.value?.color),v=o(()=>n.value?.visible);return T({appearance:a,font:r,size:i,style:l,color:c,visible:v})}function qe(e){const t=d(),n=o(()=>{const i=t.design.value[e],l=t.defaults.value[e],c=t.globalDesign.value;return{overlay:{type:i?.overlay?.type??l?.overlay?.type,solid:{color:f(c,i?.overlay?.solid?.color,l?.overlay?.solid?.color)},gradient:{fromColor:f(c,i?.overlay?.gradient?.fromColor,l?.overlay?.gradient?.fromColor),toColor:f(c,i?.overlay?.gradient?.toColor,l?.overlay?.gradient?.toColor)}},visible:i?.visible??l?.visible??!1}}),a=o(()=>n.value?.overlay),r=o(()=>n.value?.visible);return T({overlay:a,visible:r})}function Qe(){const e=d(),t=o(()=>e.design.value.layout),n=o(()=>t.value);return T({layout:n})}function Ze(){const e=d();return o(()=>{const t=e.design.value.logo,n=e.defaults.value.logo,a=e.globalDesign.value;return{font:S(a,t?.font,n?.font),size:A(a,t?.size,n?.size),bold:t?.bold??n?.bold,italic:t?.italic??n?.italic,color:f(a,t?.color,n?.color),visible:t?.visible??n?.visible??!1,spacing:t?.spacing??n?.spacing??0,capitalization:t?.capitalization??n?.capitalization??"none",frame:Ve(a,t?.frame,n?.frame)}})}function et(e){const t=d(),n=o(()=>{const r=t.design.value[e],i=t.defaults.value[e];return{value:r?.value??i?.value}}),a=o(()=>n.value?.value);return T({value:a})}function tt(e){const t=d(),n=o(()=>{const s=t.design.value[e],u=t.defaults.value[e],E=t.globalDesign.value;return{font:S(E,s?.font,u?.font),size:A(E,s?.size,u?.size),bold:s?.bold??u?.bold,italic:s?.italic??u?.italic,color:f(E,s?.color,u?.color),visible:s?.visible??u?.visible??!1}}),a=o(()=>n.value?.font),r=o(()=>n.value?.size),i=o(()=>n.value?.bold),l=o(()=>n.value?.italic),c=o(()=>n.value?.color),v=o(()=>n.value?.visible);return T({font:a,size:r,bold:i,italic:l,color:c,visible:v})}function nt(e){const t=d(),n=o(()=>{const u=t.design.value[e],E=t.defaults.value[e],g=t.globalDesign.value;return{font:S(g,u?.font,E?.font),size:A(g,u?.size,E?.size),bold:u?.bold??E?.bold,italic:u?.italic??E?.italic,color:f(g,u?.color,E?.color),visible:u?.visible??E?.visible??!1,whiteSpace:"pre-wrap"}}),a=o(()=>n.value?.font),r=o(()=>n.value?.size),i=o(()=>n.value?.bold),l=o(()=>n.value?.italic),c=o(()=>n.value?.color),v=o(()=>n.value?.visible),s=o(()=>n.value?.whiteSpace);return T({font:a,size:r,bold:i,italic:l,color:c,visible:v,whiteSpace:s})}function ot(e){const t=d(),n=o(()=>{const r=t.design.value[e],i=t.defaults.value[e];return{enabled:r?.enabled??i?.enabled}}),a=o(()=>n.value?.enabled);return T({enabled:a})}export{x as ActionLinkTypeEnum,M as BackgroundStyleEnum,N as ButtonAppearanceEnum,w as ButtonShapeEnum,h as ButtonSizeEnum,D as ButtonTypeEnum,ge as CatalogLayoutSlot,fe as CategoryLayoutSlot,B as ConfigTypeEnum,k as DesignEditorType,ne as EditorTypes,z as ImageSet,X as InstantsiteJsEvent,G as OverlayTypeEnum,P as PluginTypeEnum,Oe as ProductLayoutSlot,$ as ReservedTemplatePageNameEnum,U as SectionTypeEnum,Te as TemplateCategoriesList,K as TemplatePageEnum,Y as ValidationTypeEnum,ce as createVueClientApp,de as createVueServerApp,je as useBackgroundElementDesign,W as useButtonElementContent,Je as useButtonElementDesign,j as useCategorySelectorElementContent,Ke as useDeckElementContent,q as useImageElementContent,qe as useImageElementDesign,Q as useInputboxElementContent,ve as useInstantsiteJsApi,Qe as useLayoutElementDesign,Ye as useLogoElementContent,Ze as useLogoElementDesign,oe as useMenuElementContent,Fe as useNavigationMenuElementContent,J as useProductSelectorElementContent,Z as useSelectboxElementContent,et as useSelectboxElementDesign,tt as useTextElementDesign,ee as useTextareaElementContent,nt as useTextareaElementDesign,te as useToggleElementContent,ot as useToggleElementDesign,He as useTranslation,d as useVueBaseProps};
|
|
1
|
+
import{createSSRApp as Oe,getCurrentInstance as ge,ref as y,computed as a,reactive as g}from"vue";import{renderToString as Te}from"vue/server-renderer";import{z as m}from"zod";function M(e){return{app:Oe(e)}}const w=new Map;function E(){const e=(r,i,l,d,v,c,s,u)=>{w.set(r._uid,{context:y(i),content:y(l),design:y(d),defaults:y(v),site:y(c?.site??{}),category:y(c?.category),storeData:y(c?.storeData),globalDesign:y(s),tileId:y(u??void 0)})},t=(r,i,l,d,v,c,s)=>{const u=w.get(r._uid);u!==void 0&&(u.content.value=i,u.design.value=l,u.defaults.value=d,u.site.value=v.site??{},u.category.value=v.category,u.globalDesign.value=c,u.storeData.value=v.storeData,u.tileId.value=s)},n=ge()?.appContext.app._uid??-1,o=w.get(n);return{init:e,update:t,context:o?.context,content:o?.content,design:o?.design,defaults:o?.defaults,site:o?.site,category:o?.category,storeData:o?.storeData,globalDesign:o?.globalDesign,tileId:o?.tileId}}function fe(e,t){return{init:()=>{const{app:n}=M(e);return t?.init?.(n),{mount:(o,r)=>{E().init(n,r.context,r.data.content,r.data.design,r.data.defaults,r.data.externalContent,r.context.globalDesign,r.data.tileId),t?.mount?.(n,o,r),n.mount(o)},update:o=>{E().update(n,o.data.content,o.data.design,o.data.defaults,o.data.externalContent,o.context.globalDesign,o.data.tileId),t?.update?.(n,o)},unmount:()=>{t?.unmount?.(n),n.unmount()}}}}}function pe(){return globalThis.window.instantsite}function me(e,t){return{init:()=>{const{app:n}=M(e);return t?.init?.(n),{render:async(o,r)=>(E().init(n,o,r.content,r.design,r.defaults,r.externalContent,o.globalDesign,r.tileId),t?.render?.(n,o,r),{html:await Te(n,{context:o}),state:{context:o,data:r}})}}}}const U={SCROLL_TO_TILE:"SCROLL_TO_TILE",HYPER_LINK:"HYPER_LINK",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",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"};m.enum(Object.values(U));const Ie=U,x={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};m.enum(Object.values(x));const Le=x,P={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};m.enum(Object.values(P));const _e=P,k={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};m.enum(Object.values(k));const Ce=k,$={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};m.enum(Object.values($));const Re=$,K={COLOR:"COLOR",GRADIENT:"GRADIENT"};m.enum(Object.values(K));const be=K,X={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"};m.enum(Object.values(X));const ye=X;var z=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e[e.Layout=3]="Layout",e[e.Asset=4]="Asset",e[e.SharedFiles=5]="SharedFiles",e))(z||{}),F=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.PageTemplateDescriptor=6]="PageTemplateDescriptor",e[e.TemplateAsset=7]="TemplateAsset",e[e.Layout=8]="Layout",e[e.LayoutSettings=9]="LayoutSettings",e[e.LayoutAsset=10]="LayoutAsset",e[e.SlotServer=11]="SlotServer",e[e.SlotClient=12]="SlotClient",e[e.SharedTranslation=13]="SharedTranslation",e[e.CollectionDescriptor=14]="CollectionDescriptor",e[e.CollectionAsset=15]="CollectionAsset",e))(F||{}),Y=(e=>(e.SCROLL_TO_TILE="SCROLL_TO_TILE",e.HYPER_LINK="HYPER_LINK",e.MAIL_LINK="MAIL_LINK",e.TEL_LINK="TEL_LINK",e.GO_TO_STORE="GO_TO_STORE",e.GO_TO_STORE_LINK="GO_TO_STORE_LINK",e.GO_TO_PAGE="GO_TO_PAGE",e))(Y||{});const L={TEXTAREA:"TEXTAREA",INPUTBOX:"INPUTBOX",SELECTBOX:"SELECTBOX",IMAGE:"IMAGE",TOGGLE:"TOGGLE",BUTTON:"BUTTON",DECK:"DECK",MENU:"MENU",NAVIGATION_MENU:"NAVIGATION_MENU",LOGO:"LOGO",INFO:"INFO",DIVIDER:"DIVIDER",PRODUCT_SELECTOR:"PRODUCT_SELECTOR",CATEGORY_SELECTOR:"CATEGORY_SELECTOR"};m.enum(Object.values(L));const V={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO"};m.enum(Object.values(V));const Se=V,j={CONTENT:"Content",DESIGN:"Design"};m.enum(Object.values(j));const Ge=j,W={TEXT:"TEXT",IMAGE:"IMAGE"};m.enum(Object.values(W));const Ae=W;var H=(e=>(e.ORIGINAL="original",e.WEBP_LOW_RES="webp-200x200",e.WEBP_HI_2X_RES="webp-2000x2000",e.MOBILE_WEBP_LOW_RES="cropped-webp-100x200",e.MOBILE_WEBP_HI_RES="cropped-webp-1000x2000",e))(H||{}),J=(e=>(e.TILE_LOADED="tile-loaded",e.TILE_UNLOADED="tile-unloaded",e))(J||{});const Ne={PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},De={CATEGORY_TITLE:"MAIN_TITLE",PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},he={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"},q={apparel_footwear:"apparel_footwear",vape_smoke:"vape_smoke",home_garden:"home_garden",sport_outdoor:"sport_outdoor",jewelry_accessories:"jewelry_accessories",pet_animals:"pet_animals",bikes:"bikes",health_beauty:"health_beauty",gift_shop:"gift_shop",electronics:"electronics",other:"other"};m.enum(Object.values(q));const we=q;function Q(e){if(!e||e.length===0)return[];const t=[];function n(o){if(t.push({id:o.id,name:o.name,url:o.urlPath}),o.children&&o.children.length>0)for(const r of o.children)n(r)}for(const o of e)n(o);return t}const S={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",GO_TO_CATEGORY_LINK:"GO_TO_CATEGORY_LINK"};function Be(e){if("tileId"in e)return e.tileId;if("tileIdForScroll"in e)return e.tileIdForScroll}function Me(e){if("pageId"in e)return e.pageId;if("pageIdForNavigate"in e)return e.pageIdForNavigate}function Ue(e,t){if("pageUrl"in e)return e.pageUrl;const n=Me(e);switch(n){case"products":return"/products";case"cart":return"/cart";case"account":return"/account";case"search":return"/search";case"home":return"/"}if(t){const o=t.find(r=>r.pageId===n);if(o)return o.url}return"/"}function xe(e){if("categoryId"in e)return e.categoryId}function Pe(e){if(!e||e.length===0)return"";const t=e.find(n=>n.selected);return!t||t.main?"":`/${t.code}`}const Z=(e,t,n)=>{if(!e||t)return;const{type:o,link:r,email:i,phone:l}=e,d=E(),v=d.site?.value?.pages,c=d.site?.value?.languages,s=Pe(c),u=Ue(e,v),O=xe(e);switch(o){case S.HYPER_LINK:if(r){const f=e.linkTarget??"_blank";return()=>window.open(r,f)}break;case S.GO_TO_STORE:case S.GO_TO_STORE_LINK:return()=>window.open(`${s}/products`,"_self");case S.GO_TO_CATEGORY:case S.GO_TO_CATEGORY_LINK:const G=n?.find(f=>f.id===O)?.url;return G===void 0?()=>window.open(`${s}/404`,"_self"):()=>window.open(G,"_self");case S.MAIL_LINK:if(i)return()=>window.open(`mailto:${i}`,"_self");break;case S.TEL_LINK:if(l)return()=>window.open(`tel:${l}`,"_self");break;case S.SCROLL_TO_TILE:if(typeof document<"u")return()=>{const f=Be(e);document.getElementById(`tile-${f}`)?.scrollIntoView()};break;case S.GO_TO_PAGE:if(u)return()=>window.open(`${s}${u}`,"_self");break;default:console.error(`Unknown type of ActionLink: ${o}`)}};function ke(e){return"title"in e&&"type"in e}function $e(e,t,n,o){const r=a(()=>{const b=e.value[t];if(b!==void 0){if(ke(b))return b;throw new Error(`Element ${t} is not action link`)}}),i=a(()=>r.value?.title),l=a(()=>r.value?.type),d=a(()=>r.value?.link),v=a(()=>r.value?.email),c=a(()=>r.value?.phone),s=a(()=>r.value?.tileId?`tile-${r.value?.tileId}`:null),u=a(()=>r.value?.type==="GO_TO_STORE_LINK"?"products":r.value?.pageId),O=a(()=>r.value?.pageUrl),G=a(()=>!!i.value),f=a(()=>!!d.value),A=Z(r.value,n,o);return g({title:i,type:l,link:d,email:v,phone:c,tileDivId:s,pageId:u,pageUrl:O,hasTitle:G,hasLink:f,performAction:A})}function ee(e,t){const n=E(),o=a(()=>!!n.site?.value?.isPreviewMode),r=a(()=>{const l=n.category?.value?.categoryTree;return Q(l)}),i=a(()=>t!==void 0?t:n.content.value!==void 0?n.content.value:{});return $e(i,e,o.value,r.value)}function te({content:e,elementName:t,errorMessage:n,validatorFn:o}){return a(()=>{const r=e.value?.[t];if(r!==void 0){if(o(r))return r;throw new Error(n)}})}function Ke(e){return typeof e=="object"&&e!==null&&"categories"in e}function Xe(e){return a(()=>e.value.reduce((t,n)=>(t[n.id]=n,t),{}))}function ze(e){return e!==void 0}function Fe(e){return!!e?.trim()}function Ye({name:e,customName:t,selectionType:n}){return n==="ROOT"?e:Fe(t)?t:e}function Ve(e,t){return ze(e)&&t}function ne({itemId:e,id:t,alt:n,name:o,nameTranslated:r,customName:i,enabled:l,productsCount:d,url:v,imageUrl:c,thumbnailImageUrl:s,imageBorderInfo:u,selectionType:O}){return{itemId:e||t.toString(),id:t,alt:n,name:Ye({name:o,customName:i,selectionType:O}),nameTranslated:r,label:o,enabled:l,url:v,productsCount:d,imageUrl:c,thumbnailImageUrl:s,imageBorderInfo:u,showCategory:Ve(t,l)}}function oe(e,t,n){const o=E(),r=a(()=>t!==void 0?t:o.content.value),i=te({content:r,elementName:e,errorMessage:`Element ${e} is not a category selector type`,validatorFn:Ke}),l=a(()=>n??o.storeData?.value),d=a(()=>i.value?.categories.selectionType??"ROOT"),v=a(()=>l.value?.categories??[]),c=a(()=>i.value?.categories?.categoryIds??[]),s=a(()=>{const G=Xe(v);return d.value==="MANUAL"?i.value?.categories?.items?.map(f=>{const A=G.value[f.id];return ne({...f,...A,selectionType:d.value})})??[]:l?.value?.categories.map(f=>ne({...f,selectionType:d.value}))??[]}),u=a(()=>i.value!==void 0),O=a(()=>s.value!==void 0&&s.value.length>0);return g({categories:s,categoryIds:c,hasContent:u,hasCategories:O})}function je(e){return typeof e=="object"&&e!==null&&("products"in e||"product"in e)}function ae(e,t,n){const o=E(),r=a(()=>t!==void 0?t:o.content.value),i=te({content:r,elementName:e,errorMessage:`Element ${e} is not a product selector type`,validatorFn:je}),l=a(()=>n??o.storeData?.value),d=a(()=>i.value?.products?.selectionType??"MANUAL"),v=a(()=>i.value?.products?.productIds??[]),c=a(()=>i.value?.product?.id),s=a(()=>typeof i.value?.categoryId=="number"?i.value.categoryId:void 0),u=a(()=>{if(d.value==="CATEGORY")return s.value===0?l?.value?.products.filter(b=>b?.defaultCategoryId===0)??[]:l?.value?.products.filter(b=>s.value&&b?.categoryIds?.includes(s.value))??[];const A=c.value?[c.value]:v.value??[];return l?.value?.products?.filter(b=>A.includes(b.id))??[]}),O=a(()=>l?.value?.categories.filter(A=>A.id===s?.value)??[]),G=a(()=>i.value!==void 0&&u.value.length>0),f=a(()=>u.value!==void 0&&u.value.length>0);return g({products:u,categories:O,categoryId:s,hasContent:G,hasProducts:f})}function We(e){return"bucket"in e&&"borderInfo"in e&&"set"in e}function N(e,t){const n=new RegExp(/^https?:\/\//);return e!=null&&n.test(e)?e:`${t}/${e}`}function He(e,t){const n=a(()=>{const c=e.value[t];if(c!==void 0){if(We(c))return c;throw new Error(`Element ${t} is not image`)}}),o=a(()=>n.value===void 0?"":E().context.value.imageBuckets?.[n.value?.bucket]),r=a(()=>n.value!==void 0),i=a(()=>N(n.value?.set?.["cropped-webp-100x200"]?.url,o.value)),l=a(()=>N(n.value?.set?.["cropped-webp-1000x2000"]?.url,o.value)),d=a(()=>N(n.value?.set?.["webp-200x200"]?.url,o.value)),v=a(()=>N(n.value?.set?.["webp-2000x2000"]?.url,o.value));return g({hasContent:r,lowResolutionMobileImage:i,highResolutionMobileImage:l,lowResolutionDesktopImage:d,highResolutionDesktopImage:v})}function re(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return He(o,e)}function Je(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not inputbox`)}}),o=a(()=>n.value!==void 0&&n.value.length>0),r=a(()=>n.value);return g({hasContent:o,value:r})}function ie(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return Je(o,e)}function qe(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not selectbox`)}}),o=a(()=>n.value!==void 0),r=a(()=>n.value);return g({hasContent:o,value:r})}function le(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return qe(o,e)}function Qe(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${t} is not textarea`)}}),o=a(()=>n.value!==void 0),r=a(()=>n.value);return g({hasContent:o,value:r})}function ue(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return Qe(o,e)}function Ze(e){return"enabled"in e}function et(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(Ze(i))return i;throw new Error(`Element ${t} is not toggle`)}}),o=a(()=>n.value!==void 0),r=a(()=>n.value?.enabled);return g({hasContent:o,value:r})}function se(e,t){const n=E(),o=a(()=>t!==void 0?t:n.content.value);return et(o,e)}function tt(e){if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.cards)&&t.cards.every(n=>typeof n.settings=="object"&&n.settings!==null)}function nt(e,t,n,o){if(e==null)throw Error("Could not get a reactive ref for undefined Card");const r=e.settings[n];if(r===void 0)return r;switch(t){case L.TEXTAREA:return ue(n,e.settings);case L.INPUTBOX:return ie(n,e.settings);case L.SELECTBOX:return le(n,e.settings);case L.IMAGE:return re(n,e.settings);case L.TOGGLE:return se(n,e.settings);case L.BUTTON:return ee(n,e.settings);case L.CATEGORY_SELECTOR:return oe(n,e.settings,o);case L.PRODUCT_SELECTOR:return ae(n,e.settings,o);default:return}}function ot(e){const t=E(),n=a(()=>t.storeData?.value),o=a(()=>{const l=t.content.value[e];if(l!==void 0){if(tt(l))return l;throw new Error(`Element ${e} is not of DECK type`)}}),r=a(()=>o.value!==void 0&&o.value.cards.length>0),i=a(()=>o.value?.cards);return g({hasContent:r,cards:i,getReactiveRef:(l,d,v)=>nt(l,d,v,n.value)})}function at(e){return"type"in e&&("text"in e||"image"in e)}function D(e,t){const n=new RegExp(/^https?:\/\//);return e!==void 0&&n.test(e)?e:`${t}/${e}`}function rt(){const e=E(),t=a(()=>{const l=e.content.value.logo;if(l!==void 0){if(at(l))return l;throw new Error("Element logo is not LOGO")}}),n=a(()=>t.value?.type),o=a(()=>t.value?.text),r=a(()=>t.value?.image===void 0?"":e.context.value.imageBuckets?.[t.value.image.bucket]),i=a(()=>({lowResolutionMobileImage:D(t.value?.image?.set?.["cropped-webp-100x200"]?.url,r.value),highResolutionMobileImage:D(t.value?.image?.set?.["cropped-webp-1000x2000"]?.url,r.value),lowResolutionDesktopImage:D(t.value?.image?.set?.["webp-200x200"]?.url,r.value),highResolutionDesktopImage:D(t.value?.image?.set?.["webp-2000x2000"]?.url,r.value)}));return g({type:n,text:o,image:i})}function it(e){return e!==null&&"items"in e}function ce(e){const t=E(),n=a(()=>{const u=t.content.value[e];if(u!==void 0){if(it(u))return u;throw new Error(`Element ${e} is not an menu`)}}),o=a(()=>!!t.site?.value?.isPreviewMode),r=a(()=>{const u=t.category?.value?.categoryTree;return Q(u)}),i=a(()=>n.value!==void 0);function l(u){if(u)try{return new URL(u).pathname}catch{return u}}function d(u){return u?.map(O=>({...O,url:l(O.url)??O.url}))}const v=a(()=>d(r.value));function c(u){const O=Z(u,o.value,v.value);return{...u,performAction:O,nestedItems:u.nestedItems?.map(c)}}const s=a(()=>n.value?.items?n.value.items.map(c):[]);return g({hasContent:i,items:s})}const lt="menu";function ut(){return ce(lt)}function st(){return globalThis.craneSharedTranslation??{}}function ct(){const e=E(),t=a(()=>e.site?.value),n=a(()=>st()),o=a(()=>{const r=t.value?.languages;return r?r.find(i=>i.selected)?.code??r.find(i=>i.main)?.code??"en":"en"});return{t:r=>{const i=n.value;if(!i||Object.keys(i).length===0)return r;const l=o.value,d=i[l]?.[r];if(d!==void 0)return d;if(l!=="en"){const v=i.en?.[r];if(v!==void 0)return v}return r},currentLanguageCode:o}}function de(e,t){if(t===void 0)return;if(!t.startsWith("global."))return t.replaceAll("_"," ");const n=t.split(".").at(2);if(n!==void 0)return e.fontFamily?e.fontFamily[n].replaceAll("_"," "):void 0}function h(e,t,n){return t?de(e,t):de(e,n)}function ve(e,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const n=t.split(".").at(2);if(n!==void 0)return e.textSize?e.textSize[n]:void 0}function B(e,t,n){return t?ve(e,t):ve(e,n)}function Ee(e,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const n=t.split(".").at(2);if(n!==void 0)return e.color?e.color[n]:void 0}function I(e,t,n){return t?Ee(e,t):Ee(e,n)}function dt(e,t,n){return{visible:t?.visible??n?.visible??!1,width:t?.width??n?.width??1,color:I(e,t?.color,n?.color)}}function vt(e){const t=E(),n=a(()=>{const r=t.design.value[e],i=t.defaults.value[e],l=t.globalDesign.value;return{background:{type:r?.background?.type??i?.background?.type,solid:{color:I(l,r?.background?.solid?.color,i?.background?.solid?.color)},gradient:{fromColor:I(l,r?.background?.gradient?.fromColor,i?.background?.gradient?.fromColor),toColor:I(l,r?.background?.gradient?.toColor,i?.background?.gradient?.toColor)}}}}),o=a(()=>n.value?.background);return g({background:o})}function Et(e){const t=E(),n=a(()=>{const c=t.design.value[e],s=t.defaults.value[e],u=t.globalDesign.value;return{appearance:c?.appearance??s?.appearance,font:h(u,c?.font,s?.font),size:c?.size??s?.size,style:c?.style??s?.style,color:I(u,c?.color,s?.color),visible:c?.visible??s?.visible??!1}}),o=a(()=>n.value?.appearance),r=a(()=>n.value?.font),i=a(()=>n.value?.size),l=a(()=>n.value?.style),d=a(()=>n.value?.color),v=a(()=>n.value?.visible);return g({appearance:o,font:r,size:i,style:l,color:d,visible:v})}function Ot(e){const t=E(),n=a(()=>{const i=t.design.value[e],l=t.defaults.value[e],d=t.globalDesign.value;return{overlay:{type:i?.overlay?.type??l?.overlay?.type,solid:{color:I(d,i?.overlay?.solid?.color,l?.overlay?.solid?.color)},gradient:{fromColor:I(d,i?.overlay?.gradient?.fromColor,l?.overlay?.gradient?.fromColor),toColor:I(d,i?.overlay?.gradient?.toColor,l?.overlay?.gradient?.toColor)}},visible:i?.visible??l?.visible??!1}}),o=a(()=>n.value?.overlay),r=a(()=>n.value?.visible);return g({overlay:o,visible:r})}function gt(){const e=E(),t=a(()=>e.design.value.layout),n=a(()=>t.value);return g({layout:n})}function Tt(){const e=E();return a(()=>{const t=e.design.value.logo,n=e.defaults.value.logo,o=e.globalDesign.value;return{font:h(o,t?.font,n?.font),size:B(o,t?.size,n?.size),bold:t?.bold??n?.bold,italic:t?.italic??n?.italic,color:I(o,t?.color,n?.color),visible:t?.visible??n?.visible??!1,spacing:t?.spacing??n?.spacing??0,capitalization:t?.capitalization??n?.capitalization??"none",frame:dt(o,t?.frame,n?.frame)}})}function ft(e){const t=E(),n=a(()=>{const r=t.design.value[e],i=t.defaults.value[e];return{value:r?.value??i?.value}}),o=a(()=>n.value?.value);return g({value:o})}function pt(e){const t=E(),n=a(()=>{const c=t.design.value[e],s=t.defaults.value[e],u=t.globalDesign.value;return{font:h(u,c?.font,s?.font),size:B(u,c?.size,s?.size),bold:c?.bold??s?.bold,italic:c?.italic??s?.italic,color:I(u,c?.color,s?.color),visible:c?.visible??s?.visible??!1}}),o=a(()=>n.value?.font),r=a(()=>n.value?.size),i=a(()=>n.value?.bold),l=a(()=>n.value?.italic),d=a(()=>n.value?.color),v=a(()=>n.value?.visible);return g({font:o,size:r,bold:i,italic:l,color:d,visible:v})}function mt(e){const t=E(),n=a(()=>{const s=t.design.value[e],u=t.defaults.value[e],O=t.globalDesign.value;return{font:h(O,s?.font,u?.font),size:B(O,s?.size,u?.size),bold:s?.bold??u?.bold,italic:s?.italic??u?.italic,color:I(O,s?.color,u?.color),visible:s?.visible??u?.visible??!1,whiteSpace:"pre-wrap"}}),o=a(()=>n.value?.font),r=a(()=>n.value?.size),i=a(()=>n.value?.bold),l=a(()=>n.value?.italic),d=a(()=>n.value?.color),v=a(()=>n.value?.visible),c=a(()=>n.value?.whiteSpace);return g({font:o,size:r,bold:i,italic:l,color:d,visible:v,whiteSpace:c})}function It(e){const t=E(),n=a(()=>{const r=t.design.value[e],i=t.defaults.value[e];return{enabled:r?.enabled??i?.enabled}}),o=a(()=>n.value?.enabled);return g({enabled:o})}function T(e){return t=>"type"in t?t:{type:e,...t}}function p(e){return t=>{const{type:n,defaults:o,...r}=t,i=o?T(e)(o):void 0;return{type:e,...r,...i!==void 0?{defaults:i}:{}}}}const Lt={inputbox:p("INPUTBOX"),textarea:p("TEXTAREA"),button:p("BUTTON"),image:p("IMAGE"),toggle:p("TOGGLE"),selectbox:p("SELECTBOX"),deck:p("DECK"),menu:p("MENU"),navigationMenu:p("NAVIGATION_MENU"),logo:p("LOGO"),productSelector:p("PRODUCT_SELECTOR"),categorySelector:p("CATEGORY_SELECTOR"),divider:p("DIVIDER"),info:p("INFO"),default:{inputbox:T("INPUTBOX"),textarea:T("TEXTAREA"),button:T("BUTTON"),selectbox:T("SELECTBOX"),image:T("IMAGE"),toggle:T("TOGGLE"),divider:T("DIVIDER"),info:T("INFO"),deck:T("DECK"),logo:T("LOGO"),menu:T("MENU"),navigationMenu:T("NAVIGATION_MENU"),productSelector:T("PRODUCT_SELECTOR"),categorySelector:T("CATEGORY_SELECTOR")}};function _(e){return t=>"type"in t?t:{type:e,...t}}function C(e){return t=>{const{type:n,defaults:o,...r}=t,i=o?_(e)(o):void 0;return{type:e,...r,...i!==void 0?{defaults:i}:{}}}}const _t={text:C("TEXT"),button:C("BUTTON"),image:C("IMAGE"),toggle:C("TOGGLE"),selectbox:C("SELECTBOX"),background:C("BACKGROUND"),colorPicker:C("COLOR_PICKER"),logo:C("LOGO"),divider:C("DIVIDER"),info:C("INFO"),default:{text:_("TEXT"),button:_("BUTTON"),image:_("IMAGE"),toggle:_("TOGGLE"),selectbox:_("SELECTBOX"),background:_("BACKGROUND"),colorPicker:_("COLOR_PICKER"),logo:_("LOGO"),info:_("INFO")}};function R(e){return t=>{const{type:n,defaults:o,...r}=t,i=o,l=i&&!("type"in i)?{...i,type:e}:o;return{type:e,...r,...l!==void 0?{defaults:l}:{}}}}const Ct={init:e=>({...e}),designOverride:{text:R("TEXT"),button:R("BUTTON"),image:R("IMAGE"),toggle:R("TOGGLE"),selectbox:R("SELECTBOX"),background:R("BACKGROUND"),colorPicker:R("COLOR_PICKER"),logo:R("LOGO"),divider:R("DIVIDER"),info:R("INFO")}},Rt={init:e=>e},bt={configuration:e=>({...e}),page:e=>({...e})},yt={default:e=>{const{type:t,...n}=e;return{type:"default",...n}},custom:e=>{const{type:t,...n}=e;return{type:"custom",...n}},store:(e={})=>{const{type:t,...n}=e;return{type:"store",...n}}},St={init:e=>({...e})};export{Y as ActionLinkTypeEnum,be as BackgroundStyleEnum,_e as ButtonAppearanceEnum,Re as ButtonShapeEnum,Ce as ButtonSizeEnum,Ie as ButtonTypeEnum,Ne as CatalogLayoutSlot,De as CategoryLayoutSlot,F as ConfigTypeEnum,Se as DesignEditorType,L as EditorTypes,H as ImageSet,J as InstantsiteJsEvent,Ae as LogoTypeEnum,Le as OverlayTypeEnum,z as PluginTypeEnum,he as ProductLayoutSlot,ye as SectionTypeEnum,we as TemplateCategoriesList,Ge as ValidationTypeEnum,Lt as content,fe as createVueClientApp,me as createVueServerApp,_t as design,Ct as layout,yt as section,Rt as showcase,bt as template,St as translation,vt as useBackgroundElementDesign,ee as useButtonElementContent,Et as useButtonElementDesign,oe as useCategorySelectorElementContent,ot as useDeckElementContent,re as useImageElementContent,Ot as useImageElementDesign,ie as useInputboxElementContent,pe as useInstantsiteJsApi,gt as useLayoutElementDesign,rt as useLogoElementContent,Tt as useLogoElementDesign,ce as useMenuElementContent,ut as useNavigationMenuElementContent,ae as useProductSelectorElementContent,le as useSelectboxElementContent,ft as useSelectboxElementDesign,pt as useTextElementDesign,ue as useTextareaElementContent,mt as useTextareaElementDesign,se as useToggleElementContent,It as useToggleElementDesign,ct as useTranslation,E as useVueBaseProps};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightspeed/crane-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
"unbuild": "^3.5.0",
|
|
46
46
|
"vue": "^3.3.4"
|
|
47
47
|
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"zod": "4.1.13"
|
|
50
|
+
},
|
|
48
51
|
"peerDependencies": {
|
|
49
52
|
"vue": "^3.3.4"
|
|
50
53
|
},
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
declare module '*.vue' {
|
|
4
|
+
import type { DefineComponent } from 'vue';
|
|
5
|
+
// eslint-disable-next-line
|
|
6
|
+
const component: DefineComponent<{}, {}, any>;
|
|
7
|
+
export default component;
|
|
8
|
+
}
|
|
5
9
|
|
|
6
10
|
type ActionLinkType
|
|
7
11
|
= 'SCROLL_TO_TILE'
|
|
@@ -18,6 +22,7 @@ interface ButtonContentData {
|
|
|
18
22
|
readonly title: string;
|
|
19
23
|
readonly type: ActionLinkType;
|
|
20
24
|
readonly link?: string;
|
|
25
|
+
readonly linkTarget?: string;
|
|
21
26
|
readonly email?: string;
|
|
22
27
|
readonly phone?: string;
|
|
23
28
|
readonly tileId?: string;
|
|
@@ -87,6 +92,7 @@ interface ActionLink {
|
|
|
87
92
|
title?: string;
|
|
88
93
|
type?: ActionLinkType;
|
|
89
94
|
link?: string;
|
|
95
|
+
linkTarget?: string;
|
|
90
96
|
email?: string;
|
|
91
97
|
phone?: string;
|
|
92
98
|
tileIdForScroll?: string;
|
|
@@ -323,6 +329,12 @@ interface LegalPage {
|
|
|
323
329
|
readonly url: string | undefined;
|
|
324
330
|
}
|
|
325
331
|
|
|
332
|
+
interface PageInfo {
|
|
333
|
+
readonly pageId: string;
|
|
334
|
+
readonly title: string;
|
|
335
|
+
readonly url: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
326
338
|
interface SiteContent {
|
|
327
339
|
readonly isPreviewMode: boolean;
|
|
328
340
|
readonly reportAbuse?: ReportAbuse;
|
|
@@ -331,6 +343,7 @@ interface SiteContent {
|
|
|
331
343
|
readonly account?: Account;
|
|
332
344
|
readonly cart?: Cart;
|
|
333
345
|
readonly legalPages?: LegalPage[];
|
|
346
|
+
readonly pages?: PageInfo[];
|
|
334
347
|
}
|
|
335
348
|
|
|
336
349
|
interface ImageBorderInfo {
|
|
@@ -550,53 +563,54 @@ type MapEditorDesignTypes = {
|
|
|
550
563
|
readonly COLOR_PICKER: string;
|
|
551
564
|
readonly LOGO: string;
|
|
552
565
|
readonly DIVIDER: string;
|
|
566
|
+
readonly INFO: string;
|
|
553
567
|
};
|
|
554
568
|
|
|
555
569
|
interface TextDesignEditor {
|
|
556
570
|
readonly type: 'TEXT';
|
|
557
571
|
readonly label: string | Record<string, string>;
|
|
558
|
-
defaults
|
|
572
|
+
defaults?: Record<string, unknown>;
|
|
559
573
|
}
|
|
560
574
|
|
|
561
575
|
interface ButtonDesignEditor {
|
|
562
576
|
readonly type: 'BUTTON';
|
|
563
577
|
readonly label: string | Record<string, string>;
|
|
564
|
-
defaults
|
|
578
|
+
defaults?: Record<string, unknown>;
|
|
565
579
|
}
|
|
566
580
|
|
|
567
581
|
interface ImageDesignEditor {
|
|
568
582
|
readonly type: 'IMAGE';
|
|
569
583
|
readonly label: string | Record<string, string>;
|
|
570
|
-
defaults
|
|
584
|
+
defaults?: Record<string, unknown>;
|
|
571
585
|
}
|
|
572
586
|
|
|
573
587
|
interface ToggleDesignEditor {
|
|
574
588
|
readonly type: 'TOGGLE';
|
|
575
589
|
readonly label: string | Record<string, string>;
|
|
576
|
-
defaults
|
|
590
|
+
defaults?: Record<string, unknown>;
|
|
577
591
|
}
|
|
578
592
|
|
|
579
593
|
interface SelectboxDesignEditor {
|
|
580
594
|
readonly type: 'SELECTBOX';
|
|
581
595
|
readonly label: string | Record<string, string>;
|
|
582
|
-
defaults
|
|
596
|
+
defaults?: Record<string, unknown>;
|
|
583
597
|
}
|
|
584
598
|
|
|
585
599
|
interface BackgroundDesignEditor {
|
|
586
600
|
readonly type: 'BACKGROUND';
|
|
587
601
|
readonly label: string | Record<string, string>;
|
|
588
|
-
defaults
|
|
602
|
+
defaults?: Record<string, unknown>;
|
|
589
603
|
}
|
|
590
604
|
|
|
591
605
|
interface ColorPickerDesignEditor {
|
|
592
606
|
readonly type: 'COLOR_PICKER';
|
|
593
|
-
defaults
|
|
607
|
+
defaults?: Record<string, unknown>;
|
|
594
608
|
}
|
|
595
609
|
|
|
596
610
|
interface LogoDesignEditor {
|
|
597
611
|
readonly type: 'LOGO';
|
|
598
612
|
readonly label?: string | Record<string, string>;
|
|
599
|
-
defaults
|
|
613
|
+
defaults?: Record<string, unknown>;
|
|
600
614
|
}
|
|
601
615
|
|
|
602
616
|
interface DividerDesignEditor {
|
|
@@ -613,7 +627,8 @@ type DesignEditor
|
|
|
613
627
|
| BackgroundDesignEditor
|
|
614
628
|
| ColorPickerDesignEditor
|
|
615
629
|
| LogoDesignEditor
|
|
616
|
-
| DividerDesignEditor
|
|
630
|
+
| DividerDesignEditor
|
|
631
|
+
| InfoDesignEditor;
|
|
617
632
|
|
|
618
633
|
type InferDesignType<T extends Record<string, DesignEditor>> = {
|
|
619
634
|
readonly [P in keyof T]: MapEditorDesignTypes[T[P]['type']]
|