@lightspeed/crane-api 2.3.1 → 2.3.2-rc.1
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 +6 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/types.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.3.2 - 2026-05-21
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Add `'ALL'` selection type to `PRODUCT_SELECTOR`. When `selectionType` is `'ALL'`, the `useProductSelectorElementContent` composable returns every product from the storefront's `storeData` without filtering by `productIds` or `categoryId`.
|
|
8
|
+
|
|
3
9
|
## 2.3.1 - 2026-05-11
|
|
4
10
|
|
|
5
11
|
### Added
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSSRApp as Te,getCurrentInstance as fe,ref as y,computed as a,reactive as E}from"vue";import{renderToString as pe}from"vue/server-renderer";import{z as m}from"zod";function B(e){return{app:Te(e)}}const w=new Map;function O(){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=fe()?.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 me(e,t){return{init:()=>{const{app:n}=B(e);return t?.init?.(n),{mount:(o,r)=>{O().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=>{O().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 Ie(){return globalThis.window.instantsite}function Le(e){const t={appName:"",blockName:"",version:"",scriptUrl:"",imageBuckets:{},globalDesign:{}};return{component:e,initState(n,o,r,i){O().init(n,t,o,r,i,{},{},void 0)},updateState(n,o,r,i){O().update(n,o,r,i,{},{},void 0)}}}function _e(e,t){return{init:()=>{const{app:n}=B(e);return t?.init?.(n),{render:async(o,r)=>(O().init(n,o,r.content,r.design,r.defaults,r.externalContent,o.globalDesign,r.tileId),t?.render?.(n,o,r),{html:await pe(n,{context:o}),state:{context:o,data:r}})}}}}const Ce={SOLID:"solid",GRADIENT:"gradient",NONE:"none"},M={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(M));const Re=M,x={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};m.enum(Object.values(x));const be=x,k={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};m.enum(Object.values(k));const ye=k,P={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};m.enum(Object.values(P));const Se=P,$={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};m.enum(Object.values($));const Ae=$,K={COLOR:"COLOR",GRADIENT:"GRADIENT"};m.enum(Object.values(K));const Ne=K,X={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"};m.enum(Object.values(X));const Ge=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 I={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(I));const V={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO",ACCORDION:"ACCORDION"};m.enum(Object.values(V));const De=V,j={CONTENT:"Content",DESIGN:"Design"};m.enum(Object.values(j));const he=j,W={TEXT:"TEXT",IMAGE:"IMAGE"};m.enum(Object.values(W));const we=W;class Ue{type="STRUCTURED_COLOR";raw;hex;hsl;rgba;auto;constructor({raw:t,hex:n,hsl:o,rgba:r,auto:i}){this.raw=t,this.hex=n,this.hsl=o,this.rgba=r,this.auto=i}}function Be(e){if(e!==void 0)return{...e,type:"STRUCTURED_COLOR"}}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 Me={PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},xe={CATEGORY_TITLE:"MAIN_TITLE",PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},ke={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 Pe=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 $e(e){if("tileId"in e)return e.tileId;if("tileIdForScroll"in e)return e.tileIdForScroll}function Ke(e){if("pageId"in e)return e.pageId;if("pageIdForNavigate"in e)return e.pageIdForNavigate}function Xe(e,t){if("pageUrl"in e)return e.pageUrl;const n=Ke(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 ze(e){if("categoryId"in e)return e.categoryId}function Fe(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=O(),v=d.site?.value?.pages,c=d.site?.value?.languages,s=Fe(c),u=Xe(e,v),g=ze(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 A=n?.find(f=>f.id===g)?.url;return A===void 0?()=>window.open(`${s}/404`,"_self"):()=>window.open(A,"_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=$e(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 Ye(e){return"title"in e&&"type"in e}function Ve(e,t,n,o){const r=a(()=>{const b=e.value[t];if(b!==void 0){if(Ye(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),g=a(()=>r.value?.pageUrl),A=a(()=>!!i.value),f=a(()=>!!d.value),N=Z(r.value,n,o);return E({title:i,type:l,link:d,email:v,phone:c,tileDivId:s,pageId:u,pageUrl:g,hasTitle:A,hasLink:f,performAction:N})}function ee(e,t){const n=O(),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 Ve(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 je(e){return typeof e=="object"&&e!==null&&"categories"in e}function We(e){return a(()=>e.value.reduce((t,n)=>(t[n.id]=n,t),{}))}function He(e){return e!==void 0}function Je(e){return!!e?.trim()}function qe({name:e,customName:t,selectionType:n}){return n==="ROOT"?e:Je(t)?t:e}function Qe(e,t){return He(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:g}){return{itemId:e||t.toString(),id:t,alt:n,name:qe({name:o,customName:i,selectionType:g}),nameTranslated:r,label:o,enabled:l,url:v,productsCount:d,imageUrl:c,thumbnailImageUrl:s,imageBorderInfo:u,showCategory:Qe(t,l)}}function oe(e,t,n){const o=O(),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:je}),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 A=We(v);return d.value==="MANUAL"?i.value?.categories?.items?.map(f=>{const N=A.value[f.id];return ne({...f,...N,selectionType:d.value})})??[]:l?.value?.categories.map(f=>ne({...f,selectionType:d.value}))??[]}),u=a(()=>i.value!==void 0),g=a(()=>s.value!==void 0&&s.value.length>0);return E({categories:s,categoryIds:c,hasContent:u,hasCategories:g})}function Ze(e){return typeof e=="object"&&e!==null&&("products"in e||"product"in e)}function ae(e,t,n){const o=O(),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:Ze}),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 N=c.value?[c.value]:v.value??[];return l?.value?.products?.filter(b=>N.includes(b.id))??[]}),g=a(()=>l?.value?.categories.filter(N=>N.id===s?.value)??[]),A=a(()=>i.value!==void 0&&u.value.length>0),f=a(()=>u.value!==void 0&&u.value.length>0);return E({products:u,categories:g,categoryId:s,hasContent:A,hasProducts:f})}function et(e){return"bucket"in e&&"set"in e}function G(e,t){const n=new RegExp(/^https?:\/\//);return e!=null&&n.test(e)?e:`${t}/${e}`}function tt(e,t){const n=a(()=>{const c=e.value[t];if(c!==void 0){if(et(c))return c;throw new Error(`Element ${t} is not image`)}}),o=a(()=>n.value===void 0?"":O().context.value.imageBuckets?.[n.value?.bucket]),r=a(()=>n.value!==void 0),i=a(()=>G(n.value?.set?.["cropped-webp-100x200"]?.url,o.value)),l=a(()=>G(n.value?.set?.["cropped-webp-1000x2000"]?.url,o.value)),d=a(()=>G(n.value?.set?.["webp-200x200"]?.url,o.value)),v=a(()=>G(n.value?.set?.["webp-2000x2000"]?.url,o.value));return E({hasContent:r,lowResolutionMobileImage:i,highResolutionMobileImage:l,lowResolutionDesktopImage:d,highResolutionDesktopImage:v})}function re(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return tt(o,e)}function nt(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 E({hasContent:o,value:r})}function ie(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return nt(o,e)}function ot(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 E({hasContent:o,value:r})}function le(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return ot(o,e)}function at(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&&n.value.length>0),r=a(()=>n.value);return E({hasContent:o,value:r})}function ue(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return at(o,e)}function rt(e){return"enabled"in e}function it(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(rt(i))return i;throw new Error(`Element ${t} is not toggle`)}}),o=a(()=>n.value!==void 0),r=a(()=>n.value?.enabled);return E({hasContent:o,value:r})}function se(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return it(o,e)}function ce(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 de(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 I.TEXTAREA:return ue(n,e.settings);case I.INPUTBOX:return ie(n,e.settings);case I.SELECTBOX:return le(n,e.settings);case I.IMAGE:return re(n,e.settings);case I.TOGGLE:return se(n,e.settings);case I.BUTTON:return ee(n,e.settings);case I.CATEGORY_SELECTOR:return oe(n,e.settings,o);case I.PRODUCT_SELECTOR:return ae(n,e.settings,o);case I.DECK:return lt(e,n,o);default:return}}function lt(e,t,n){const o=a(()=>{const l=e.settings[t];if(l!==void 0){if(ce(l))return l;throw new Error(`Element ${t} is not of DECK type`)}}),r=a(()=>o.value!==void 0&&o.value.cards.length>0),i=a(()=>o.value?.cards);return E({hasContent:r,cards:i,getReactiveRef:(l,d,v)=>de(l,d,v,n)})}function ut(e){const t=O(),n=a(()=>t.storeData?.value),o=a(()=>{const l=t.content.value[e];if(l!==void 0){if(ce(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 E({hasContent:r,cards:i,getReactiveRef:(l,d,v)=>de(l,d,v,n.value)})}function st(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 ct(){const e=O(),t=a(()=>{const l=e.content.value.logo;if(l!==void 0){if(st(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 E({type:n,text:o,image:i})}function dt(e){return e!==null&&"items"in e}function ve(e){const t=O(),n=a(()=>{const u=t.content.value[e];if(u!==void 0){if(dt(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(g=>({...g,url:l(g.url)??g.url}))}const v=a(()=>d(r.value));function c(u){const g=Z(u,o.value,v.value);return{...u,performAction:g,nestedItems:u.nestedItems?.map(c)}}const s=a(()=>n.value?.items?n.value.items.map(c):[]);return E({hasContent:i,items:s})}const vt="menu";function Ot(){return ve(vt)}function Et(){return globalThis.craneSharedTranslation??{}}function gt(){const e=O(),t=a(()=>e.site?.value),n=a(()=>Et()),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 Tt(e){const t=O(),n=a(()=>t.design.value[e]),o=a(()=>{const l=n.value?.items;return l!==void 0&&Object.keys(l).length>0}),r=a(()=>n.value?.items),i=a(()=>n.value?.sortable??!1);return E({hasItems:o,items:r,sortable:i})}function Oe(e,t){if(t===void 0)return;if(!t.startsWith("global."))return t.replaceAll("_"," ");const n=t.split(".").at(2);return n===void 0?void 0:e.fontFamily?.[n]?.replaceAll("_"," ")}function h(e,t,n){return t?Oe(e,t):Oe(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.textSize?e.textSize[n]:void 0}function U(e,t,n){return t?Ee(e,t):Ee(e,n)}function ge(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 L(e,t,n){return t?ge(e,t):ge(e,n)}function ft(e,t,n){return{visible:t?.visible??n?.visible??!1,width:t?.width??n?.width??1,color:L(e,t?.color,n?.color)}}function pt(e){const t=O(),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:L(l,r?.background?.solid?.color,i?.background?.solid?.color)},gradient:{fromColor:L(l,r?.background?.gradient?.fromColor,i?.background?.gradient?.fromColor),toColor:L(l,r?.background?.gradient?.toColor,i?.background?.gradient?.toColor)}}}}),o=a(()=>n.value?.background);return E({background:o})}function mt(e){const t=O(),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:L(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 E({appearance:o,font:r,size:i,style:l,color:d,visible:v.value??!1})}function It(e){const t=O(),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:L(d,i?.overlay?.solid?.color,l?.overlay?.solid?.color)},gradient:{fromColor:L(d,i?.overlay?.gradient?.fromColor,l?.overlay?.gradient?.fromColor),toColor:L(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 E({overlay:o,visible:r})}function Lt(){const e=O(),t=a(()=>e.design.value.layout),n=a(()=>t.value);return E({layout:n})}function _t(){const e=O();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:U(o,t?.size,n?.size),bold:t?.bold??n?.bold,italic:t?.italic??n?.italic,color:L(o,t?.color,n?.color),visible:t?.visible??n?.visible??!1,spacing:t?.spacing??n?.spacing??0,capitalization:t?.capitalization??n?.capitalization??"none",frame:ft(o,t?.frame,n?.frame)}})}function Ct(e){const t=O(),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 E({value:o})}function Rt(e){const t=O(),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:U(u,c?.size,s?.size),bold:c?.bold??s?.bold,italic:c?.italic??s?.italic,color:L(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 E({font:o,size:r,bold:i,italic:l,color:d,visible:v})}function bt(e){const t=O(),n=a(()=>{const s=t.design.value[e],u=t.defaults.value[e],g=t.globalDesign.value;return{font:h(g,s?.font,u?.font),size:U(g,s?.size,u?.size),bold:s?.bold??u?.bold,italic:s?.italic??u?.italic,color:L(g,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 E({font:o,size:r,bold:i,italic:l,color:d,visible:v,whiteSpace:c})}function yt(e){const t=O(),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 E({enabled:o})}const St={configuration:e=>({metadata:{...e.metadata},sections:[...e.sections]})};function T(e){return t=>{const{type:n}=t;return"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 At={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=>{const{type:n}=t;return"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 Nt={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"),accordion:C("ACCORDION"),default:{text:_("TEXT"),button:_("BUTTON"),image:_("IMAGE"),toggle:_("TOGGLE"),selectbox:_("SELECTBOX"),background:_("BACKGROUND"),colorPicker:_("COLOR_PICKER"),logo:_("LOGO"),accordion:_("ACCORDION"),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 Gt={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"),accordion:R("ACCORDION")}},Dt={init:e=>e},ht={configuration:e=>({...e}),page:e=>({...e})},wt={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}}},Ut={init:e=>({...e})};export{Y as ActionLinkTypeEnum,Ne as BackgroundStyleEnum,ye as ButtonAppearanceEnum,Ae as ButtonShapeEnum,Se as ButtonSizeEnum,Re as ButtonTypeEnum,Me as CatalogLayoutSlot,xe as CategoryLayoutSlot,Ue as Color,F as ConfigTypeEnum,De as DesignEditorType,I as EditorTypes,H as ImageSet,J as InstantsiteJsEvent,we as LogoTypeEnum,Ce as OverlayType,be as OverlayTypeEnum,z as PluginTypeEnum,ke as ProductLayoutSlot,Ge as SectionTypeEnum,Pe as TemplateCategoriesList,he as ValidationTypeEnum,Be as asStructuredColor,St as collection,At as content,Le as createLayoutApp,me as createVueClientApp,_e as createVueServerApp,Nt as design,Gt as layout,wt as section,Dt as showcase,ht as template,Ut as translation,Tt as useAccordionElementDesign,pt as useBackgroundElementDesign,ee as useButtonElementContent,mt as useButtonElementDesign,oe as useCategorySelectorElementContent,ut as useDeckElementContent,re as useImageElementContent,It as useImageElementDesign,ie as useInputboxElementContent,Ie as useInstantsiteJsApi,Lt as useLayoutElementDesign,ct as useLogoElementContent,_t as useLogoElementDesign,ve as useMenuElementContent,Ot as useNavigationMenuElementContent,ae as useProductSelectorElementContent,le as useSelectboxElementContent,Ct as useSelectboxElementDesign,Rt as useTextElementDesign,ue as useTextareaElementContent,bt as useTextareaElementDesign,se as useToggleElementContent,yt as useToggleElementDesign,gt as useTranslation,O as useVueBaseProps};
|
|
1
|
+
import{createSSRApp as Te,getCurrentInstance as fe,ref as y,computed as a,reactive as E}from"vue";import{renderToString as pe}from"vue/server-renderer";import{z as m}from"zod";function B(e){return{app:Te(e)}}const w=new Map;function O(){const e=(r,i,l,c,v,d,s,u)=>{w.set(r._uid,{context:y(i),content:y(l),design:y(c),defaults:y(v),site:y(d?.site??{}),category:y(d?.category),storeData:y(d?.storeData),globalDesign:y(s),tileId:y(u??void 0)})},t=(r,i,l,c,v,d,s)=>{const u=w.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=d,u.storeData.value=v.storeData,u.tileId.value=s)},n=fe()?.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 me(e,t){return{init:()=>{const{app:n}=B(e);return t?.init?.(n),{mount:(o,r)=>{O().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=>{O().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 Ie(){return globalThis.window.instantsite}function Le(e){const t={appName:"",blockName:"",version:"",scriptUrl:"",imageBuckets:{},globalDesign:{}};return{component:e,initState(n,o,r,i){O().init(n,t,o,r,i,{},{},void 0)},updateState(n,o,r,i){O().update(n,o,r,i,{},{},void 0)}}}function _e(e,t){return{init:()=>{const{app:n}=B(e);return t?.init?.(n),{render:async(o,r)=>(O().init(n,o,r.content,r.design,r.defaults,r.externalContent,o.globalDesign,r.tileId),t?.render?.(n,o,r),{html:await pe(n,{context:o}),state:{context:o,data:r}})}}}}const Ce={SOLID:"solid",GRADIENT:"gradient",NONE:"none"},M={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(M));const Re=M,x={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};m.enum(Object.values(x));const be=x,k={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};m.enum(Object.values(k));const ye=k,P={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};m.enum(Object.values(P));const Se=P,$={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};m.enum(Object.values($));const Ae=$,K={COLOR:"COLOR",GRADIENT:"GRADIENT"};m.enum(Object.values(K));const Ne=K,X={SECTION:"SECTION",HEADER:"HEADER",FOOTER:"FOOTER"};m.enum(Object.values(X));const Ge=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 I={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(I));const V={TEXT:"TEXT",BUTTON:"BUTTON",IMAGE:"IMAGE",TOGGLE:"TOGGLE",SELECTBOX:"SELECTBOX",BACKGROUND:"BACKGROUND",COLOR_PICKER:"COLOR_PICKER",LOGO:"LOGO",DIVIDER:"DIVIDER",INFO:"INFO",ACCORDION:"ACCORDION"};m.enum(Object.values(V));const De=V,j={CONTENT:"Content",DESIGN:"Design"};m.enum(Object.values(j));const he=j,W={TEXT:"TEXT",IMAGE:"IMAGE"};m.enum(Object.values(W));const we=W;class Ue{type="STRUCTURED_COLOR";raw;hex;hsl;rgba;auto;constructor({raw:t,hex:n,hsl:o,rgba:r,auto:i}){this.raw=t,this.hex=n,this.hsl=o,this.rgba=r,this.auto=i}}function Be(e){if(e!==void 0)return{...e,type:"STRUCTURED_COLOR"}}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 Me={PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},xe={CATEGORY_TITLE:"MAIN_TITLE",PRODUCT_LIST:"CONTROLS",BOTTOM_BAR:"FOOTER",CUSTOM_SLOT:"CUSTOM_SLOT"},ke={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 Pe=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 $e(e){if("tileId"in e)return e.tileId;if("tileIdForScroll"in e)return e.tileIdForScroll}function Ke(e){if("pageId"in e)return e.pageId;if("pageIdForNavigate"in e)return e.pageIdForNavigate}function Xe(e,t){if("pageUrl"in e)return e.pageUrl;const n=Ke(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 ze(e){if("categoryId"in e)return e.categoryId}function Fe(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,c=O(),v=c.site?.value?.pages,d=c.site?.value?.languages,s=Fe(d),u=Xe(e,v),g=ze(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 A=n?.find(f=>f.id===g)?.url;return A===void 0?()=>window.open(`${s}/404`,"_self"):()=>window.open(A,"_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=$e(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 Ye(e){return"title"in e&&"type"in e}function Ve(e,t,n,o){const r=a(()=>{const b=e.value[t];if(b!==void 0){if(Ye(b))return b;throw new Error(`Element ${t} is not action link`)}}),i=a(()=>r.value?.title),l=a(()=>r.value?.type),c=a(()=>r.value?.link),v=a(()=>r.value?.email),d=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),g=a(()=>r.value?.pageUrl),A=a(()=>!!i.value),f=a(()=>!!c.value),N=Z(r.value,n,o);return E({title:i,type:l,link:c,email:v,phone:d,tileDivId:s,pageId:u,pageUrl:g,hasTitle:A,hasLink:f,performAction:N})}function ee(e,t){const n=O(),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 Ve(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 je(e){return typeof e=="object"&&e!==null&&"categories"in e}function We(e){return a(()=>e.value.reduce((t,n)=>(t[n.id]=n,t),{}))}function He(e){return e!==void 0}function Je(e){return!!e?.trim()}function qe({name:e,customName:t,selectionType:n}){return n==="ROOT"?e:Je(t)?t:e}function Qe(e,t){return He(e)&&t}function ne({itemId:e,id:t,alt:n,name:o,nameTranslated:r,customName:i,enabled:l,productsCount:c,url:v,imageUrl:d,thumbnailImageUrl:s,imageBorderInfo:u,selectionType:g}){return{itemId:e||t.toString(),id:t,alt:n,name:qe({name:o,customName:i,selectionType:g}),nameTranslated:r,label:o,enabled:l,url:v,productsCount:c,imageUrl:d,thumbnailImageUrl:s,imageBorderInfo:u,showCategory:Qe(t,l)}}function oe(e,t,n){const o=O(),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:je}),l=a(()=>n??o.storeData?.value),c=a(()=>i.value?.categories.selectionType??"ROOT"),v=a(()=>l.value?.categories??[]),d=a(()=>i.value?.categories?.categoryIds??[]),s=a(()=>{const A=We(v);return c.value==="MANUAL"?i.value?.categories?.items?.map(f=>{const N=A.value[f.id];return ne({...f,...N,selectionType:c.value})})??[]:l?.value?.categories.map(f=>ne({...f,selectionType:c.value}))??[]}),u=a(()=>i.value!==void 0),g=a(()=>s.value!==void 0&&s.value.length>0);return E({categories:s,categoryIds:d,hasContent:u,hasCategories:g})}function Ze(e){return typeof e=="object"&&e!==null&&("products"in e||"product"in e)}function ae(e,t,n){const o=O(),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:Ze}),l=a(()=>n??o.storeData?.value),c=a(()=>i.value?.products?.selectionType??"MANUAL"),v=a(()=>i.value?.products?.productIds??[]),d=a(()=>i.value?.product?.id),s=a(()=>typeof i.value?.categoryId=="number"?i.value.categoryId:void 0),u=a(()=>{if(c.value==="ALL")return l?.value?.products??[];if(c.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 N=d.value?[d.value]:v.value??[];return l?.value?.products?.filter(b=>N.includes(b.id))??[]}),g=a(()=>l?.value?.categories.filter(N=>N.id===s?.value)??[]),A=a(()=>i.value!==void 0&&u.value.length>0),f=a(()=>u.value!==void 0&&u.value.length>0);return E({products:u,categories:g,categoryId:s,hasContent:A,hasProducts:f})}function et(e){return"bucket"in e&&"set"in e}function G(e,t){const n=new RegExp(/^https?:\/\//);return e!=null&&n.test(e)?e:`${t}/${e}`}function tt(e,t){const n=a(()=>{const d=e.value[t];if(d!==void 0){if(et(d))return d;throw new Error(`Element ${t} is not image`)}}),o=a(()=>n.value===void 0?"":O().context.value.imageBuckets?.[n.value?.bucket]),r=a(()=>n.value!==void 0),i=a(()=>G(n.value?.set?.["cropped-webp-100x200"]?.url,o.value)),l=a(()=>G(n.value?.set?.["cropped-webp-1000x2000"]?.url,o.value)),c=a(()=>G(n.value?.set?.["webp-200x200"]?.url,o.value)),v=a(()=>G(n.value?.set?.["webp-2000x2000"]?.url,o.value));return E({hasContent:r,lowResolutionMobileImage:i,highResolutionMobileImage:l,lowResolutionDesktopImage:c,highResolutionDesktopImage:v})}function re(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return tt(o,e)}function nt(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 E({hasContent:o,value:r})}function ie(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return nt(o,e)}function ot(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 E({hasContent:o,value:r})}function le(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return ot(o,e)}function at(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&&n.value.length>0),r=a(()=>n.value);return E({hasContent:o,value:r})}function ue(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return at(o,e)}function rt(e){return"enabled"in e}function it(e,t){const n=a(()=>{const i=e.value[t];if(i!==void 0){if(rt(i))return i;throw new Error(`Element ${t} is not toggle`)}}),o=a(()=>n.value!==void 0),r=a(()=>n.value?.enabled);return E({hasContent:o,value:r})}function se(e,t){const n=O(),o=a(()=>t!==void 0?t:n.content.value);return it(o,e)}function ce(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 de(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 I.TEXTAREA:return ue(n,e.settings);case I.INPUTBOX:return ie(n,e.settings);case I.SELECTBOX:return le(n,e.settings);case I.IMAGE:return re(n,e.settings);case I.TOGGLE:return se(n,e.settings);case I.BUTTON:return ee(n,e.settings);case I.CATEGORY_SELECTOR:return oe(n,e.settings,o);case I.PRODUCT_SELECTOR:return ae(n,e.settings,o);case I.DECK:return lt(e,n,o);default:return}}function lt(e,t,n){const o=a(()=>{const l=e.settings[t];if(l!==void 0){if(ce(l))return l;throw new Error(`Element ${t} is not of DECK type`)}}),r=a(()=>o.value!==void 0&&o.value.cards.length>0),i=a(()=>o.value?.cards);return E({hasContent:r,cards:i,getReactiveRef:(l,c,v)=>de(l,c,v,n)})}function ut(e){const t=O(),n=a(()=>t.storeData?.value),o=a(()=>{const l=t.content.value[e];if(l!==void 0){if(ce(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 E({hasContent:r,cards:i,getReactiveRef:(l,c,v)=>de(l,c,v,n.value)})}function st(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 ct(){const e=O(),t=a(()=>{const l=e.content.value.logo;if(l!==void 0){if(st(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 E({type:n,text:o,image:i})}function dt(e){return e!==null&&"items"in e}function ve(e){const t=O(),n=a(()=>{const u=t.content.value[e];if(u!==void 0){if(dt(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 c(u){return u?.map(g=>({...g,url:l(g.url)??g.url}))}const v=a(()=>c(r.value));function d(u){const g=Z(u,o.value,v.value);return{...u,performAction:g,nestedItems:u.nestedItems?.map(d)}}const s=a(()=>n.value?.items?n.value.items.map(d):[]);return E({hasContent:i,items:s})}const vt="menu";function Ot(){return ve(vt)}function Et(){return globalThis.craneSharedTranslation??{}}function gt(){const e=O(),t=a(()=>e.site?.value),n=a(()=>Et()),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,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:o}}function Tt(e){const t=O(),n=a(()=>t.design.value[e]),o=a(()=>{const l=n.value?.items;return l!==void 0&&Object.keys(l).length>0}),r=a(()=>n.value?.items),i=a(()=>n.value?.sortable??!1);return E({hasItems:o,items:r,sortable:i})}function Oe(e,t){if(t===void 0)return;if(!t.startsWith("global."))return t.replaceAll("_"," ");const n=t.split(".").at(2);return n===void 0?void 0:e.fontFamily?.[n]?.replaceAll("_"," ")}function h(e,t,n){return t?Oe(e,t):Oe(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.textSize?e.textSize[n]:void 0}function U(e,t,n){return t?Ee(e,t):Ee(e,n)}function ge(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 L(e,t,n){return t?ge(e,t):ge(e,n)}function ft(e,t,n){return{visible:t?.visible??n?.visible??!1,width:t?.width??n?.width??1,color:L(e,t?.color,n?.color)}}function pt(e){const t=O(),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:L(l,r?.background?.solid?.color,i?.background?.solid?.color)},gradient:{fromColor:L(l,r?.background?.gradient?.fromColor,i?.background?.gradient?.fromColor),toColor:L(l,r?.background?.gradient?.toColor,i?.background?.gradient?.toColor)}}}}),o=a(()=>n.value?.background);return E({background:o})}function mt(e){const t=O(),n=a(()=>{const d=t.design.value[e],s=t.defaults.value[e],u=t.globalDesign.value;return{appearance:d?.appearance??s?.appearance,font:h(u,d?.font,s?.font),size:d?.size??s?.size,style:d?.style??s?.style,color:L(u,d?.color,s?.color),visible:d?.visible??s?.visible??!1}}),o=a(()=>n.value?.appearance),r=a(()=>n.value?.font),i=a(()=>n.value?.size),l=a(()=>n.value?.style),c=a(()=>n.value?.color),v=a(()=>n.value?.visible);return E({appearance:o,font:r,size:i,style:l,color:c,visible:v.value??!1})}function It(e){const t=O(),n=a(()=>{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:L(c,i?.overlay?.solid?.color,l?.overlay?.solid?.color)},gradient:{fromColor:L(c,i?.overlay?.gradient?.fromColor,l?.overlay?.gradient?.fromColor),toColor:L(c,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 E({overlay:o,visible:r})}function Lt(){const e=O(),t=a(()=>e.design.value.layout),n=a(()=>t.value);return E({layout:n})}function _t(){const e=O();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:U(o,t?.size,n?.size),bold:t?.bold??n?.bold,italic:t?.italic??n?.italic,color:L(o,t?.color,n?.color),visible:t?.visible??n?.visible??!1,spacing:t?.spacing??n?.spacing??0,capitalization:t?.capitalization??n?.capitalization??"none",frame:ft(o,t?.frame,n?.frame)}})}function Ct(e){const t=O(),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 E({value:o})}function Rt(e){const t=O(),n=a(()=>{const d=t.design.value[e],s=t.defaults.value[e],u=t.globalDesign.value;return{font:h(u,d?.font,s?.font),size:U(u,d?.size,s?.size),bold:d?.bold??s?.bold,italic:d?.italic??s?.italic,color:L(u,d?.color,s?.color),visible:d?.visible??s?.visible??!1}}),o=a(()=>n.value?.font),r=a(()=>n.value?.size),i=a(()=>n.value?.bold),l=a(()=>n.value?.italic),c=a(()=>n.value?.color),v=a(()=>n.value?.visible);return E({font:o,size:r,bold:i,italic:l,color:c,visible:v})}function bt(e){const t=O(),n=a(()=>{const s=t.design.value[e],u=t.defaults.value[e],g=t.globalDesign.value;return{font:h(g,s?.font,u?.font),size:U(g,s?.size,u?.size),bold:s?.bold??u?.bold,italic:s?.italic??u?.italic,color:L(g,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),c=a(()=>n.value?.color),v=a(()=>n.value?.visible),d=a(()=>n.value?.whiteSpace);return E({font:o,size:r,bold:i,italic:l,color:c,visible:v,whiteSpace:d})}function yt(e){const t=O(),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 E({enabled:o})}const St={configuration:e=>({metadata:{...e.metadata},sections:[...e.sections]})};function T(e){return t=>{const{type:n}=t;return"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 At={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=>{const{type:n}=t;return"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 Nt={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"),accordion:C("ACCORDION"),default:{text:_("TEXT"),button:_("BUTTON"),image:_("IMAGE"),toggle:_("TOGGLE"),selectbox:_("SELECTBOX"),background:_("BACKGROUND"),colorPicker:_("COLOR_PICKER"),logo:_("LOGO"),accordion:_("ACCORDION"),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 Gt={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"),accordion:R("ACCORDION")}},Dt={init:e=>e},ht={configuration:e=>({...e}),page:e=>({...e})},wt={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}}},Ut={init:e=>({...e})};export{Y as ActionLinkTypeEnum,Ne as BackgroundStyleEnum,ye as ButtonAppearanceEnum,Ae as ButtonShapeEnum,Se as ButtonSizeEnum,Re as ButtonTypeEnum,Me as CatalogLayoutSlot,xe as CategoryLayoutSlot,Ue as Color,F as ConfigTypeEnum,De as DesignEditorType,I as EditorTypes,H as ImageSet,J as InstantsiteJsEvent,we as LogoTypeEnum,Ce as OverlayType,be as OverlayTypeEnum,z as PluginTypeEnum,ke as ProductLayoutSlot,Ge as SectionTypeEnum,Pe as TemplateCategoriesList,he as ValidationTypeEnum,Be as asStructuredColor,St as collection,At as content,Le as createLayoutApp,me as createVueClientApp,_e as createVueServerApp,Nt as design,Gt as layout,wt as section,Dt as showcase,ht as template,Ut as translation,Tt as useAccordionElementDesign,pt as useBackgroundElementDesign,ee as useButtonElementContent,mt as useButtonElementDesign,oe as useCategorySelectorElementContent,ut as useDeckElementContent,re as useImageElementContent,It as useImageElementDesign,ie as useInputboxElementContent,Ie as useInstantsiteJsApi,Lt as useLayoutElementDesign,ct as useLogoElementContent,_t as useLogoElementDesign,ve as useMenuElementContent,Ot as useNavigationMenuElementContent,ae as useProductSelectorElementContent,le as useSelectboxElementContent,Ct as useSelectboxElementDesign,Rt as useTextElementDesign,ue as useTextareaElementContent,bt as useTextareaElementDesign,se as useToggleElementContent,yt as useToggleElementDesign,gt as useTranslation,O as useVueBaseProps};
|
package/package.json
CHANGED