@askdialog/dialog-vue 3.4.1 → 3.5.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/dist/dialog-vue.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(S,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(S=typeof globalThis<"u"?globalThis:S||self,e(S["dialog-vue"]={},S.Vue))})(this,(function(S,e){"use strict";var
|
|
1
|
+
(function(S,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(S=typeof globalThis<"u"?globalThis:S||self,e(S["dialog-vue"]={},S.Vue))})(this,(function(S,e){"use strict";var Ct=Object.defineProperty;var bt=(S,e,R)=>e in S?Ct(S,e,{enumerable:!0,configurable:!0,writable:!0,value:R}):S[e]=R;var V=(S,e,R)=>bt(S,typeof e!="symbol"?e+"":e,R);const R=new Set(["ar","he","iw","fa","ur"]),Q=o=>o!==void 0&&R.has(o.trim().toLowerCase().slice(0,2)),W=o=>Q(o)?"rtl":"ltr",v=o=>{try{return new Intl.Locale(o).language}catch{return o}};var N;(function(o){o.OPEN_ASSISTANT="open_assistant",o.CLOSE_ASSISTANT="close_assistant",o.SEND_MESSAGE="PRODUCT_QUESTION",o.SEND_GENERIC_QUESTION="GENERIC_QUESTION",o.TRACK_ADD_TO_CART="TRACK_ADD_TO_CART",o.TRACK_SUBMIT_CHECKOUT="TRACK_SUBMIT_CHECKOUT",o.TRACK_VIEW_SEARCH_RESULTS="TRACK_VIEW_SEARCH_RESULTS",o.TRACK_SELECT_SEARCH_RESULT="TRACK_SELECT_SEARCH_RESULT"})(N||(N={}));var P;(function(o){o.USER_OPENED_ASSISTANT="userOpenedAssistant",o.USER_CLOSED_ASSISTANT="userClosedAssistant",o.USER_SENT_MESSAGE="userSentMessage",o.USER_CLICKED_ON_PRODUCT_CARD="userClickedOnProductCard",o.USER_OPENED_RECOMMENDATION="userOpenedRecommendation",o.USER_ADDED_TO_CART="userAddedToCart",o.USER_SEND_POSITIVE_FEEDBACK="userSendPositiveFeedback",o.USER_SEND_NEGATIVE_FEEDBACK="userSendNegativeFeedback"})(P||(P={})),N.TRACK_ADD_TO_CART,N.TRACK_SUBMIT_CHECKOUT,N.TRACK_VIEW_SEARCH_RESULTS,N.TRACK_SELECT_SEARCH_RESULT;class Y extends Error{constructor({status:n,code:s,message:l}){super(l);V(this,"status");V(this,"code");this.name="DialogSearchError",this.status=n,this.code=s}}const z=(o,t)=>`${o}_${v(t)}`,O="multiple installation methods detected:",X=()=>typeof window>"u"?void 0:window,U=()=>{const o=X();if(o!==void 0)return o.dialog=o.dialog??{},o.dialog.audit=o.dialog.audit??{methods:[],context:{},capabilities:[],warnings:[]},o.dialog.audit},Z=o=>{if(o.warnings=o.warnings.filter(t=>!t.startsWith(O)),o.methods.length>=2){const t=o.methods.map(n=>n.method).join(", ");o.warnings.push(`${O} ${t}`)}},J=(o,t)=>t===void 0?o:{version:(o==null?void 0:o.version)??t.version,commit:(o==null?void 0:o.commit)??t.commit},M=o=>{const t=U();if(t===void 0)return;const n=t.methods.find(s=>s.method===o.method);if(n===void 0){t.methods.push({...o,registeredAt:new Date().toISOString()}),Z(t);return}n.version=n.version??o.version,n.build=J(n.build,o.build),n.source=n.source??o.source},ee=o=>{const t=U();t!==void 0&&(t.capabilities.includes(o)||t.capabilities.push(o))},y={IDLE:"idle",LOADING:"loading",SUCCESS:"success",EMPTY:"empty",ERROR:"error"},te=.5,oe=500,ne=1500,se=100;function re({emit:o,visibilityThreshold:t=te,dwellMs:n=oe,idleFlushMs:s=ne,maxItemsPerEvent:l=se}){let r,c=[];const a=new Set,d=new Map,_=new Map;let u;const p=()=>{clearTimeout(u),!(r===void 0||c.length===0)&&(o({...r,items:c}),c=[])},g=m=>{if(r===void 0)return;const E=`${r.query_id}:${m.product_id}`;if(!a.has(E)){if(a.add(E),c.push(m),c.length>=l){p();return}clearTimeout(u),u=setTimeout(p,s)}},C=m=>{const E=_.get(m);E!==void 0&&(clearTimeout(E),_.delete(m))},i=new IntersectionObserver(m=>{for(const E of m){const h=d.get(E.target);h!==void 0&&(E.intersectionRatio>=t?_.has(E.target)||_.set(E.target,setTimeout(()=>{_.delete(E.target),g(h)},n)):C(E.target))}},{threshold:t}),k=()=>{i.disconnect();for(const m of _.values())clearTimeout(m);_.clear(),d.clear()},b=()=>{p()},w=m=>{if(m.persisted){a.clear();for(const E of d.keys())C(E),i.unobserve(E),i.observe(E)}};return window.addEventListener("pagehide",b),window.addEventListener("pageshow",w),{setContext(m){p(),a.clear(),r=m,k()},observe(m,E){d.set(m,E),i.observe(m)},forceImpression(m){g(m),p()},flush:p,disconnect(){p(),k(),window.removeEventListener("pagehide",b),window.removeEventListener("pageshow",w)}}}const x=(o,t)=>({product_id:o.hits[t].objectID,position:o.page*o.hitsPerPage+t+1});function ce(o){let t,n;const s=()=>(t??(t=re({emit:o.trackViewSearchResults})),t);return{onResponse(l){n={query_id:l.queryID,index:l.index,surface:o.surface,search_type:"lexical",page:l.page+1,total_hits:l.nbHits,query_length:[...l.query].length},s().setContext(n),l.nbHits===0&&o.trackViewSearchResults({...n,items:[]})},observeResult(l,r,c){s().observe(l,x(r,c))},select(l,r){if(n===void 0)return;const c=x(l,r);s().forceImpression(c),o.trackSelectSearchResult({...n,items:[c]})},dispose(){t==null||t.disconnect()}}}const ae=250,le=12,ie=2,q={status:y.IDLE,query:"",page:0,response:void 0,error:void 0};function de({search:o,analytics:t,navigate:n,debounceMs:s=ae,hitsPerPage:l=le,locale:r}){const c=z("products",r);let a=q;const d=new Set,_=ce(t);let u,p,g,C=0,i=!1;const k=h=>{a={...a,...h};for(const f of d)f(a)},b=()=>{clearTimeout(u),g==null||g.abort(),g=void 0},w=(h,f)=>({requests:[{indexName:c,query:h,page:f,hitsPerPage:l}]}),m=async(h,f)=>{b(),g=new AbortController;const T=++C,L=w(h,f);k({status:y.LOADING,query:h,page:f});try{const B=await o(L,{signal:g.signal});if(T!==C)return;const A=B.results.find(kt=>kt.index===c);if(A===void 0)throw new Error(`Dialog search returned no ${c} entry`);_.onResponse(A),k({status:A.nbHits===0?y.EMPTY:y.SUCCESS,response:A,error:void 0})}catch(B){if(B instanceof DOMException&&B.name==="AbortError"||T!==C)return;k({status:y.ERROR,error:B,response:void 0})}},E=h=>{const f=h.trim();if(b(),p=void 0,[...f].length<ie){C+=1,k(q);return}return f};return{setQuery(h){const f=i?void 0:E(h);f!==void 0&&(p=f,u=setTimeout(()=>{p=void 0,m(f,0)},s))},submit(h){const f=i?void 0:E(h);f!==void 0&&m(f,0)},setPage(h){if(!i){if(p!==void 0){const f=p;p=void 0,m(f,0);return}a.query!==""&&m(a.query,h)}},retry(){i||a.status!==y.ERROR||m(a.query,a.page)},observeResult(h,f){a.response!==void 0&&_.observeResult(h,a.response,f)},selectResult(h,f){const T=a.response;if(T===void 0)return!1;_.select(T,h);const L=T.hits[h].url;return((f==null?void 0:f.navigate)??!0)&&n!==void 0&&L!==void 0?(n(L,T.hits[h]),!0):!1},subscribe(h){return d.add(h),()=>{d.delete(h)}},getState:()=>a,dispose(){i=!0,b(),C+=1,p=void 0,d.clear(),_.dispose()}}}const ue={class:"dialog-block-header-container"},pe={class:"dialog-block-title"},_e={class:"dialog-block-description"},me=e.defineComponent({__name:"DialogBlockHeader",props:{title:{},description:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("div",ue,[e.createElementVNode("div",pe,e.toDisplayString(t.title??"Your expert"),1),e.createElementVNode("div",_e,e.toDisplayString(t.description??"A question about this product?"),1)]))}}),I=(o,t)=>{const n=o.__vccOpts||o;for(const[s,l]of t)n[s]=l;return n},he=I(me,[["__scopeId","data-v-28e6dda7"]]),fe={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ge={"clip-path":"url(#clip0_466_934)"},Ee=["stroke"],Se=["stroke"],ke=e.defineComponent({__name:"AiStarsIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",fe,[e.createElementVNode("g",ge,[e.createElementVNode("path",{d:`M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011
|
|
2
2
|
12.9962C6.68124 13.1663 6.83375 13.3188 7.00388 13.45C7.19559 13.5977 7.41684
|
|
3
3
|
13.7084 7.85932 13.9296L9.16675 14.5833L7.85932 15.237C7.41684 15.4583 7.19559
|
|
4
4
|
15.5689 7.00388 15.7167C6.83375 15.8478 6.68124 16.0003 6.55011 16.1704C6.40232
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
15.7167C3.6379 15.5689 3.41666 15.4583 2.97418 15.237L1.66675 14.5833L2.97418
|
|
8
8
|
13.9296C3.41666 13.7084 3.6379 13.5977 3.82962 13.45C3.99974 13.3188 4.15225
|
|
9
9
|
13.1663 4.28339 12.9962C4.43117 12.8045 4.54179 12.5832 4.76303 12.1408L5.41675
|
|
10
|
-
10.8333Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,
|
|
10
|
+
10.8333Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,Ee),e.createElementVNode("path",{d:`M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175
|
|
11
11
|
5.39386C14.1795 5.62162 14.3785 5.82061 14.6062 5.98256C14.8632 6.16529 15.1687
|
|
12
12
|
6.2828 15.7797 6.5178L18.3334 7.49999L15.7797 8.48217C15.1687 8.71718 14.8632
|
|
13
13
|
8.83469 14.6062 9.01742C14.3785 9.17937 14.1795 9.37836 14.0175 9.60612C13.8348
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
9.01742C10.137 8.83469 9.83145 8.71718 9.22043 8.48217L6.66675 7.49999L9.22043
|
|
17
17
|
6.5178C9.83145 6.28279 10.137 6.16529 10.3939 5.98256C10.6217 5.82061 10.8207
|
|
18
18
|
5.62162 10.9827 5.39386C11.1654 5.13688 11.2829 4.83136 11.5179 4.22034L12.5001
|
|
19
|
-
1.66666Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,ge)]),r[0]||(r[0]=e.createElementVNode("defs",null,[e.createElementVNode("clipPath",{id:"clip0_466_934"},[e.createElementVNode("rect",{width:"20",height:"20",fill:"white"})])],-1))]))}}),Se=["onClick"],ke={class:"dialog-block-suggestions-item-label"},Ce=N(e.defineComponent({__name:"DialogBlockSuggestions",props:{client:{},questions:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=r=>{t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:r,fromQuestionSuggestion:!0})};return(r,i)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.questions,c=>(e.openBlock(),e.createElementBlock("button",{key:c.question,class:"dialog-block-suggestions-item",onClick:a=>n(c.question)},[e.createVNode(Ee,{class:"dialog-block-suggestions-item-icon",color:t.client.theme.primaryColor},null,8,["color"]),e.createElementVNode("span",ke,e.toDisplayString(c.question),1)],8,Se))),128))}}),[["__scopeId","data-v-db34d4b4"]]),be={};function ye(o,t){return e.openBlock(),e.createElementBlock(e.Fragment,null,[t[0]||(t[0]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1)),t[1]||(t[1]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1)),t[2]||(t[2]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1))],64)}const Te=N(be,[["render",ye],["__scopeId","data-v-26a64b58"]]),we={class:"dialog-block-suggestions-container"},Re=N(e.defineComponent({__name:"DialogBlockSuggestionsContainer",props:{client:{},questions:{},isLoading:{type:Boolean},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o;return(n,r)=>(e.openBlock(),e.createElementBlock("div",we,[t.isLoading||!t.questions?(e.openBlock(),e.createBlock(Te,{key:0})):(e.openBlock(),e.createBlock(Ce,{key:1,client:t.client,questions:t.questions,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t.selectedVariantId},null,8,["client","questions","product-id","product-title","selected-variant-id"]))]))}}),[["__scopeId","data-v-18c9e78b"]]),Ie={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Ne=["stroke"],Be=e.defineComponent({__name:"ArrowIcon",props:{color:{}},setup(o){const t=o;return(n,r)=>(e.openBlock(),e.createElementBlock("svg",Ie,[e.createElementVNode("path",{d:"M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",stroke:t.color||"#ffffff","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,Ne)]))}}),De=["placeholder"],Ae=["disabled"],x=N(e.defineComponent({__name:"DialogInput",props:{client:{},placeholder:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=e.ref(),r=e.ref(""),i=()=>{var a;(a=n.value)==null||a.focus()},c=()=>{const a=r.value;a.trim()&&(t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:a,fromQuestionSuggestion:!0}),r.value="")};return(a,s)=>(e.openBlock(),e.createElementBlock("div",{class:"dialog-input-wrapper",onClick:i},[e.withDirectives(e.createElementVNode("input",{id:"dialog-ask-anything-input-ai-input",ref_key:"inputRef",ref:n,"onUpdate:modelValue":s[0]||(s[0]=p=>r.value=p),class:"dialog-ask-anything-input-ai-input",placeholder:t.placeholder??"Ask anything...",onKeydown:e.withKeys(c,["enter"])},null,40,De),[[e.vModelText,r.value]]),e.createElementVNode("button",{id:"send-message-button-ai-input",class:"dialog-input-submit",disabled:!r.value.trim(),onClick:c},[e.createVNode(Be,{color:t.client.theme.ctaTextColor},null,8,["color"])],8,Ae)]))}}),[["__scopeId","data-v-4f5901c9"]]),Le=e.defineComponent({__name:"ThemeProvider",props:{theme:{}},setup(o){const t=o,n=document.body,r=c=>c.replace(/([A-Z])/g,"-$1").toLowerCase(),i=c=>{c&&Object.keys(c).forEach(a=>{const s=a,p=r(a);if(c[s]!==void 0){if(typeof c[s]=="object"){Object.keys(c[s]).forEach(_=>{var u;const d=_;if(d!==void 0){const g=r(_),C=c[s];n.style.setProperty(`--dialog-theme-${p}-${g}`,(u=C[d])==null?void 0:u.toString())}});return}if(s==="ctaBorderType"){const _=c[s]==="rounded"?"24px":"0";n.style.setProperty(`--dialog-theme-${p}`,_);return}n.style.setProperty(`--dialog-theme-${p}`,c[s].toString())}})};return e.onMounted(()=>{t.theme&&i(t.theme)}),e.watch(()=>t.theme,c=>{c&&i(c)},{deep:!0}),(c,a)=>e.renderSlot(c.$slots,"default")}}),Ve=["dir"],$e=N(e.defineComponent({__name:"DialogProductBlock",props:{client:{},productId:{},productTitle:{},selectedVariantId:{default:void 0},enableInput:{type:Boolean,default:!0}},setup(o){const t=o;e.onMounted(()=>{U({method:"vue",version:"3.4.1"}),v("pdp-block")});const n=e.ref(!0),r=e.ref(void 0),i=e.ref(0),c=e.computed(()=>{var d;return n.value?"":(d=r.value)==null?void 0:d.assistantName}),a=e.computed(()=>{var d;return n.value?"":(d=r.value)==null?void 0:d.description}),s=e.computed(()=>{var d;return n.value?"":(d=r.value)==null?void 0:d.inputPlaceholder}),p=e.computed(()=>{var d;return W((d=t.client.getLocalizationInformations())==null?void 0:d.languageCode)}),_=async()=>{const d=++i.value;n.value=!0,r.value=void 0;try{const u=await t.client.getSuggestions(t.productId);d===i.value&&(r.value=u)}catch(u){console.error("error",u)}finally{d===i.value&&(n.value=!1)}};return e.watch(()=>[t.client,t.productId],()=>{_()},{immediate:!0}),(d,u)=>(e.openBlock(),e.createBlock(Le,{theme:t.client.theme},{default:e.withCtx(()=>{var g;return[e.createElementVNode("div",{id:"dialog-instant",class:"dialog-block-container",dir:p.value},[e.createVNode(me,{title:c.value,description:a.value},null,8,["title","description"]),e.createVNode(Re,{client:t.client,questions:(g=r.value)==null?void 0:g.questions,"is-loading":n.value,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t==null?void 0:t.selectedVariantId},null,8,["client","questions","is-loading","product-id","product-title","selected-variant-id"]),t.enableInput?(e.openBlock(),e.createBlock(x,{key:0,client:t.client,placeholder:s.value,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t==null?void 0:t.selectedVariantId},null,8,["client","placeholder","product-id","product-title","selected-variant-id"])):e.createCommentVNode("",!0)],8,Ve)]}),_:1},8,["theme"]))}}),[["__scopeId","data-v-c57aa677"]]),Pe={},Oe={width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"};function Ue(o,t){return e.openBlock(),e.createElementBlock("svg",Oe,t[0]||(t[0]=[e.createElementVNode("path",{d:"M8 13V3M8 3L3 8M8 3L13 8",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]))}const Me=N(Pe,[["render",Ue]]),qe={width:"16",height:"16",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},xe=["fill"],He="M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z",Ke=e.defineComponent({__name:"ShurikenIcon",props:{color:{}},setup(o){const t=o;return(n,r)=>(e.openBlock(),e.createElementBlock("svg",qe,[e.createElementVNode("path",{d:He,fill:t.color||"currentColor"},null,8,xe)]))}}),Fe={class:"dialog-search-bar-field"},Ge={class:"dialog-search-bar-icon"},je=["aria-label","placeholder","autofocus"],Qe=["aria-label"],We=e.defineComponent({__name:"DialogSearchBar",props:{controller:{},placeholder:{default:"Search products..."},autoFocus:{type:Boolean,default:!1},submitAriaLabel:{default:"Search"}},setup(o){const t=o,n=e.ref(""),r=()=>{t.controller.setQuery(n.value)},i=()=>{t.controller.submit(n.value)};return(c,a)=>(e.openBlock(),e.createElementBlock("form",{class:"dialog-search-bar",role:"search",onSubmit:e.withModifiers(i,["prevent"])},[e.createElementVNode("div",Fe,[e.createElementVNode("span",Ge,[e.createVNode(Ke)]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=s=>n.value=s),type:"text",name:"dialog-search-query",class:"dialog-search-bar-input","aria-label":t.placeholder,placeholder:t.placeholder,autofocus:t.autoFocus,onInput:r},null,40,je),[[e.vModelText,n.value]])]),e.createElementVNode("button",{type:"submit",class:"dialog-search-bar-submit","aria-label":t.submitAriaLabel},[e.createVNode(Me)],8,Qe)],32))}}),Ye={key:0,"aria-label":"Search results pages",class:"dialog-search-pagination"},ze=["disabled"],Xe=["disabled"],H=e.defineComponent({__name:"DialogSearchPagination",props:{controller:{},state:{}},setup(o){const t=o,n=e.computed(()=>t.state.response);return(r,i)=>n.value!==void 0&&n.value.nbPages>1?(e.openBlock(),e.createElementBlock("nav",Ye,[e.createElementVNode("button",{type:"button",disabled:n.value.page===0,onClick:i[0]||(i[0]=c=>t.controller.setPage(n.value.page-1))}," Previous ",8,ze),e.createElementVNode("span",null," Page "+e.toDisplayString(n.value.page+1)+" / "+e.toDisplayString(n.value.nbPages),1),e.createElementVNode("button",{type:"button",disabled:n.value.page>=n.value.nbPages-1,onClick:i[1]||(i[1]=c=>t.controller.setPage(n.value.page+1))}," Next ",8,Xe)])):e.createCommentVNode("",!0)}}),L=({amount:o,currencyCode:t},n)=>new Intl.NumberFormat(n,{style:"currency",currency:t}).format(Number(o)),K=({min:o,max:t},n)=>o.amount===t.amount?L(o,n):`${L(o,n)} – ${L(t,n)}`,Ze=(o,t)=>{if(o===void 0)return"";try{return K(o,t)}catch{return""}},ve=(o,t)=>{const n=o.priceRange,r=o.compareAtPriceRange;if(n===void 0||r===void 0||Number(r.min.amount)<=Number(n.min.amount))return"";try{return K(r,t)}catch{return""}},Je=o=>{try{const{protocol:t}=new URL(o,window.location.href);return t==="http:"||t==="https:"?o:void 0}catch{return}},et={class:"dialog-search-card-image"},tt=["src","alt"],ot={class:"dialog-search-card-info"},nt={class:"dialog-search-card-title"},rt={key:0,class:"dialog-search-card-price"},st={key:0,class:"dialog-search-card-compare-at"},F=e.defineComponent({__name:"DialogSearchProductCardContent",props:{hit:{},locale:{}},setup(o){const t=o,n=e.computed(()=>t.hit.product.title??t.hit.product.id),r=e.computed(()=>Ze(t.hit.product.priceRange,t.locale)),i=e.computed(()=>ve(t.hit.product,t.locale));return(c,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",et,[t.hit.product.imageUrl!==void 0?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.hit.product.imageUrl,alt:n.value,loading:"lazy"},null,8,tt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",ot,[e.createElementVNode("p",nt,e.toDisplayString(n.value),1),r.value!==""?(e.openBlock(),e.createElementBlock("p",rt,[e.createTextVNode(e.toDisplayString(r.value),1),i.value!==""?(e.openBlock(),e.createElementBlock("s",st,e.toDisplayString(" "+i.value),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])],64))}}),ct={key:0,class:"dialog-search-card-body"},at=["href"],G=e.defineComponent({__name:"DialogSearchProductCard",props:{controller:{},hit:{},index:{},locale:{}},setup(o){const t=o,n=e.ref();e.watch(()=>t.hit,()=>{n.value!==void 0&&t.controller.observeResult(n.value,t.index)},{immediate:!0,flush:"post"});const r=a=>{const s=a.metaKey||a.ctrlKey||a.shiftKey||a.altKey;t.controller.selectResult(t.index,{navigate:!s})&&a.preventDefault()},i=a=>{a.button===1&&t.controller.selectResult(t.index,{navigate:!1})},c=e.computed(()=>t.hit.product.url===void 0?void 0:Je(t.hit.product.url));return(a,s)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"cardRef",ref:n,class:"dialog-search-card"},[c.value===void 0?(e.openBlock(),e.createElementBlock("div",ct,[e.createVNode(F,{hit:t.hit,locale:t.locale},null,8,["hit","locale"])])):(e.openBlock(),e.createElementBlock("a",{key:1,class:"dialog-search-card-body",href:c.value,onClick:r,onAuxclick:i},[e.createVNode(F,{hit:t.hit,locale:t.locale},null,8,["hit","locale"])],40,at))],512))}}),it=o=>{const t=e.ref(),n=e.ref(void 0),r=e.ref(0);return e.watch(o,(i,c,a)=>{if(!i)return;const s=()=>{const p=t.value;if(p===void 0)return;const _=p.previousElementSibling??p,{top:d,bottom:u,left:g,width:C}=_.getBoundingClientRect();r.value=window.innerHeight;const l=n.value;(l===void 0||l.top!==d||l.bottom!==u||l.left!==g||l.width!==C)&&(n.value={top:d,bottom:u,left:g,width:C})};s(),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),a(()=>{window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)})},{immediate:!0,flush:"post"}),{anchorRef:t,rect:n,viewportHeight:r}},lt=(o,t)=>{const n=e.ref(!1),r=e.ref(),i=e.computed(()=>o.value.status!==y.IDLE&&!n.value);e.watch(()=>o.value.query,()=>{n.value=!1}),e.watch(i,(a,s,p)=>{if(!a)return;const _=d=>{var k,b;const u=d.target;if(!(u instanceof Node))return;const g=(k=t.value)==null?void 0:k.previousElementSibling,C=((b=r.value)==null?void 0:b.contains(u))??!1,l=(g==null?void 0:g.contains(u))??!1;!C&&!l&&(n.value=!0)};document.addEventListener("pointerdown",_),p(()=>document.removeEventListener("pointerdown",_))},{immediate:!0});const c=()=>{n.value=!1};return e.onMounted(()=>{var a,s;(s=(a=t.value)==null?void 0:a.previousElementSibling)==null||s.addEventListener("focusin",c)}),e.onUnmounted(()=>{var a,s;(s=(a=t.value)==null?void 0:a.previousElementSibling)==null||s.removeEventListener("focusin",c)}),{isOpen:i,panelRef:r}},dt={key:0,role:"status",class:"dialog-search-status"},ut={key:1,class:"dialog-search-error"},pt={role:"alert",class:"dialog-search-status dialog-search-status-error"},mt={key:2,role:"status",class:"dialog-search-status"},_t={role:"status",class:"dialog-search-status"},ht={class:"dialog-search-results"},A=8,j=16,ft=200,gt=e.defineComponent({__name:"DialogSearchResults",props:{controller:{},state:{},locale:{}},setup(o){const t=o,n=l=>l instanceof Y?`Search failed (${l.status}${l.code?` ${l.code}`:""}): ${l.message}`:"Search failed: network error. Check your connection and try again.",r=(l,k)=>l.bottom>0&&l.top<k,i=(l,k)=>{const b=k-l.bottom-A-j,w=l.top-A-j,m={left:`${l.left}px`,width:`${l.width}px`};return b<ft&&w>b?{...m,bottom:`${k-l.top+A}px`,maxHeight:`${Math.max(w,0)}px`}:{...m,top:`${l.bottom+A}px`,maxHeight:`${Math.max(b,0)}px`}},c=e.computed(()=>t.state),a=e.computed(()=>t.state.status!==y.IDLE),{anchorRef:s,rect:p,viewportHeight:_}=it(a),{isOpen:d,panelRef:u}=lt(c,s),g=e.computed(()=>d.value&&p.value!==void 0&&r(p.value,_.value)),C=e.computed(()=>p.value===void 0?void 0:i(p.value,_.value));return(l,k)=>{var b;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{ref_key:"anchorRef",ref:s},null,512),g.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[e.createElementVNode("div",{ref_key:"panelRef",ref:u,class:"dialog-search-panel",style:e.normalizeStyle(C.value)},[t.state.status===e.unref(y).LOADING?(e.openBlock(),e.createElementBlock("p",dt," Searching “"+e.toDisplayString(t.state.query)+"”… ",1)):t.state.status===e.unref(y).ERROR?(e.openBlock(),e.createElementBlock("div",ut,[e.createElementVNode("p",pt,e.toDisplayString(n(t.state.error)),1),e.createElementVNode("button",{type:"button",class:"dialog-search-retry",onClick:k[0]||(k[0]=w=>t.controller.retry())}," Retry ")])):t.state.status===e.unref(y).EMPTY?(e.openBlock(),e.createElementBlock("p",mt," No products match “"+e.toDisplayString((b=t.state.response)==null?void 0:b.query)+"”. ",1)):t.state.status===e.unref(y).SUCCESS&&t.state.response!==void 0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("p",_t,e.toDisplayString(t.state.response.nbHits)+" result"+e.toDisplayString(t.state.response.nbHits>1?"s":""),1),e.createElementVNode("ul",ht,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.state.response.hits,(w,m)=>(e.openBlock(),e.createBlock(G,{key:w.id,controller:t.controller,hit:w,index:m,locale:t.locale},null,8,["controller","hit","index","locale"]))),128))]),e.createVNode(H,{controller:t.controller,state:t.state},null,8,["controller","state"])],64)):e.createCommentVNode("",!0)],4)])):e.createCommentVNode("",!0)],64)}}}),Et=o=>{const{client:t,surface:n="search_page",...r}=o,i=ie({search:(s,p)=>t.search(s,p),analytics:{surface:n,trackViewSearchResults:s=>t.trackViewSearchResults(s),trackSelectSearchResult:s=>t.trackSelectSearchResult(s)},...r}),c=e.shallowRef(i.getState()),a=i.subscribe(()=>{c.value=i.getState()});return e.onMounted(()=>{U({method:"vue",version:"3.4.1"})}),e.onUnmounted(()=>{a(),i.dispose()}),{controller:i,state:c}};S.DialogInput=x,S.DialogProductBlock=$e,S.DialogSearchBar=We,S.DialogSearchPagination=H,S.DialogSearchProductCard=G,S.DialogSearchResults=gt,S.useDialogSearch=Et,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
|
|
19
|
+
1.66666Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,Se)]),s[0]||(s[0]=e.createElementVNode("defs",null,[e.createElementVNode("clipPath",{id:"clip0_466_934"},[e.createElementVNode("rect",{width:"20",height:"20",fill:"white"})])],-1))]))}}),Ce=["onClick"],be={class:"dialog-block-suggestions-item-label"},ye=I(e.defineComponent({__name:"DialogBlockSuggestions",props:{client:{},questions:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=s=>{t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:s,fromQuestionSuggestion:!0})};return(s,l)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.questions,r=>(e.openBlock(),e.createElementBlock("button",{key:r.question,class:"dialog-block-suggestions-item",onClick:c=>n(r.question)},[e.createVNode(ke,{class:"dialog-block-suggestions-item-icon",color:t.client.theme.primaryColor},null,8,["color"]),e.createElementVNode("span",be,e.toDisplayString(r.question),1)],8,Ce))),128))}}),[["__scopeId","data-v-db34d4b4"]]),we={};function Ie(o,t){return e.openBlock(),e.createElementBlock(e.Fragment,null,[t[0]||(t[0]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1)),t[1]||(t[1]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1)),t[2]||(t[2]=e.createElementVNode("div",{class:"dialog-block-suggestions-skeleton-item"},null,-1))],64)}const Te=I(we,[["render",Ie],["__scopeId","data-v-26a64b58"]]),Re={class:"dialog-block-suggestions-container"},Ne=I(e.defineComponent({__name:"DialogBlockSuggestionsContainer",props:{client:{},questions:{},isLoading:{type:Boolean},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("div",Re,[t.isLoading||!t.questions?(e.openBlock(),e.createBlock(Te,{key:0})):(e.openBlock(),e.createBlock(ye,{key:1,client:t.client,questions:t.questions,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t.selectedVariantId},null,8,["client","questions","product-id","product-title","selected-variant-id"]))]))}}),[["__scopeId","data-v-18c9e78b"]]),Be={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},De=["stroke"],Le=e.defineComponent({__name:"ArrowIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",Be,[e.createElementVNode("path",{d:"M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",stroke:t.color||"#ffffff","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,De)]))}}),Ae=["placeholder"],$e=["disabled"],H=I(e.defineComponent({__name:"DialogInput",props:{client:{},placeholder:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=e.ref(),s=e.ref(""),l=()=>{var c;(c=n.value)==null||c.focus()},r=()=>{const c=s.value;c.trim()&&(t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:c,fromQuestionSuggestion:!0}),s.value="")};return(c,a)=>(e.openBlock(),e.createElementBlock("div",{class:"dialog-input-wrapper",onClick:l},[e.withDirectives(e.createElementVNode("input",{id:"dialog-ask-anything-input-ai-input",ref_key:"inputRef",ref:n,"onUpdate:modelValue":a[0]||(a[0]=d=>s.value=d),class:"dialog-ask-anything-input-ai-input",placeholder:t.placeholder??"Ask anything...",onKeydown:e.withKeys(r,["enter"])},null,40,Ae),[[e.vModelText,s.value]]),e.createElementVNode("button",{id:"send-message-button-ai-input",class:"dialog-input-submit",disabled:!s.value.trim(),onClick:r},[e.createVNode(Le,{color:t.client.theme.ctaTextColor},null,8,["color"])],8,$e)]))}}),[["__scopeId","data-v-4f5901c9"]]),Ve=e.defineComponent({__name:"ThemeProvider",props:{theme:{}},setup(o){const t=o,n=document.body,s=r=>r.replace(/([A-Z])/g,"-$1").toLowerCase(),l=r=>{r&&Object.keys(r).forEach(c=>{const a=c,d=s(c);if(r[a]!==void 0){if(typeof r[a]=="object"){Object.keys(r[a]).forEach(_=>{var p;const u=_;if(u!==void 0){const g=s(_),C=r[a];n.style.setProperty(`--dialog-theme-${d}-${g}`,(p=C[u])==null?void 0:p.toString())}});return}if(a==="ctaBorderType"){const _=r[a]==="rounded"?"24px":"0";n.style.setProperty(`--dialog-theme-${d}`,_);return}n.style.setProperty(`--dialog-theme-${d}`,r[a].toString())}})};return e.onMounted(()=>{t.theme&&l(t.theme)}),e.watch(()=>t.theme,r=>{r&&l(r)},{deep:!0}),(r,c)=>e.renderSlot(r.$slots,"default")}}),Pe=["dir"],Oe=I(e.defineComponent({__name:"DialogProductBlock",props:{client:{},productId:{},productTitle:{},selectedVariantId:{default:void 0},enableInput:{type:Boolean,default:!0}},setup(o){const t=o;e.onMounted(()=>{M({method:"vue",version:"3.5.0"}),ee("pdp-block")});const n=e.ref(!0),s=e.ref(void 0),l=e.ref(0),r=e.computed(()=>{var u;return n.value?"":(u=s.value)==null?void 0:u.assistantName}),c=e.computed(()=>{var u;return n.value?"":(u=s.value)==null?void 0:u.description}),a=e.computed(()=>{var u;return n.value?"":(u=s.value)==null?void 0:u.inputPlaceholder}),d=e.computed(()=>{var u;return W((u=t.client.getLocalizationInformations())==null?void 0:u.languageCode)}),_=async()=>{const u=++l.value;n.value=!0,s.value=void 0;try{const p=await t.client.getSuggestions(t.productId);u===l.value&&(s.value=p)}catch(p){console.error("error",p)}finally{u===l.value&&(n.value=!1)}};return e.watch(()=>[t.client,t.productId],()=>{_()},{immediate:!0}),(u,p)=>(e.openBlock(),e.createBlock(Ve,{theme:t.client.theme},{default:e.withCtx(()=>{var g;return[e.createElementVNode("div",{id:"dialog-instant",class:"dialog-block-container",dir:d.value},[e.createVNode(he,{title:r.value,description:c.value},null,8,["title","description"]),e.createVNode(Ne,{client:t.client,questions:(g=s.value)==null?void 0:g.questions,"is-loading":n.value,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t==null?void 0:t.selectedVariantId},null,8,["client","questions","is-loading","product-id","product-title","selected-variant-id"]),t.enableInput?(e.openBlock(),e.createBlock(H,{key:0,client:t.client,placeholder:a.value,"product-id":t.productId,"product-title":t.productTitle,"selected-variant-id":t==null?void 0:t.selectedVariantId},null,8,["client","placeholder","product-id","product-title","selected-variant-id"])):e.createCommentVNode("",!0)],8,Pe)]}),_:1},8,["theme"]))}}),[["__scopeId","data-v-c57aa677"]]),Ue={},Me={width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"};function xe(o,t){return e.openBlock(),e.createElementBlock("svg",Me,t[0]||(t[0]=[e.createElementVNode("path",{d:"M8 13V3M8 3L3 8M8 3L13 8",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]))}const qe=I(Ue,[["render",xe]]),He={width:"16",height:"16",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},Ke=["fill"],Fe="M5.3217 0.588255C5.63241 -0.196084 6.36759 -0.196085 6.6783 0.588254C6.98901 1.37259 7.68193 2.82807 8.42693 3.57307C9.17193 4.31807 10.6274 5.01099 11.4117 5.3217C12.1961 5.63241 12.1961 6.36759 11.4117 6.6783C10.6274 6.98901 9.17193 7.68193 8.42693 8.42693C7.68193 9.17193 6.98901 10.6274 6.6783 11.4117C6.36759 12.1961 5.63241 12.1961 5.3217 11.4117C5.01099 10.6274 4.31807 9.17193 3.57307 8.42693C2.82808 7.68193 1.37259 6.98901 0.588255 6.6783C-0.196084 6.36759 -0.196085 5.63241 0.588254 5.3217C1.37259 5.01099 2.82807 4.31807 3.57307 3.57307C4.31807 2.82808 5.01099 1.37259 5.3217 0.588255Z",je=e.defineComponent({__name:"ShurikenIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",He,[e.createElementVNode("path",{d:Fe,fill:t.color||"currentColor"},null,8,Ke)]))}}),Ge={class:"dialog-search-bar-field"},Qe={class:"dialog-search-bar-icon"},We=["aria-label","placeholder","autofocus"],ve=["aria-label"],Ye=e.defineComponent({__name:"DialogSearchBar",props:{controller:{},placeholder:{default:"Search products..."},autoFocus:{type:Boolean,default:!1},submitAriaLabel:{default:"Search"}},setup(o){const t=o,n=e.ref(""),s=()=>{t.controller.setQuery(n.value)},l=()=>{t.controller.submit(n.value)};return(r,c)=>(e.openBlock(),e.createElementBlock("form",{class:"dialog-search-bar",role:"search",onSubmit:e.withModifiers(l,["prevent"])},[e.createElementVNode("div",Ge,[e.createElementVNode("span",Qe,[e.createVNode(je)]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":c[0]||(c[0]=a=>n.value=a),type:"text",name:"dialog-search-query",class:"dialog-search-bar-input","aria-label":t.placeholder,placeholder:t.placeholder,autofocus:t.autoFocus,onInput:s},null,40,We),[[e.vModelText,n.value]])]),e.createElementVNode("button",{type:"submit",class:"dialog-search-bar-submit","aria-label":t.submitAriaLabel},[e.createVNode(qe)],8,ve)],32))}}),ze={key:0,"aria-label":"Search results pages",class:"dialog-search-pagination"},Xe=["disabled"],Ze=["disabled"],K=e.defineComponent({__name:"DialogSearchPagination",props:{controller:{},state:{}},setup(o){const t=o,n=e.computed(()=>t.state.response);return(s,l)=>n.value!==void 0&&n.value.nbPages>1?(e.openBlock(),e.createElementBlock("nav",ze,[e.createElementVNode("button",{type:"button",disabled:n.value.page===0,onClick:l[0]||(l[0]=r=>t.controller.setPage(n.value.page-1))}," Previous ",8,Xe),e.createElementVNode("span",null," Page "+e.toDisplayString(n.value.page+1)+" / "+e.toDisplayString(n.value.nbPages),1),e.createElementVNode("button",{type:"button",disabled:n.value.page>=n.value.nbPages-1,onClick:l[1]||(l[1]=r=>t.controller.setPage(n.value.page+1))}," Next ",8,Ze)])):e.createCommentVNode("",!0)}}),$=({amount:o,currencyCode:t},n)=>t===void 0?new Intl.NumberFormat(n).format(Number(o)):new Intl.NumberFormat(n,{style:"currency",currency:t}).format(Number(o)),Je=({min:o,max:t},n)=>o.amount===t.amount?$(o,n):`${$(o,n)} – ${$(t,n)}`,et=(o,t)=>{if(o===void 0)return"";try{return Je(o,t)}catch{return""}},tt=o=>{try{const{protocol:t}=new URL(o,window.location.href);return t==="http:"||t==="https:"?o:void 0}catch{return}},ot={class:"dialog-search-card-image"},nt=["src","alt"],st={class:"dialog-search-card-info"},rt={class:"dialog-search-card-title"},ct={key:0,class:"dialog-search-card-price"},F=e.defineComponent({__name:"DialogSearchProductCardContent",props:{hit:{},locale:{}},setup(o){const t=o,n=e.computed(()=>t.hit.title??t.hit.objectID),s=e.computed(()=>et(t.hit.priceRange,t.locale));return(l,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ot,[t.hit.imageUrl!==void 0?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.hit.imageUrl,alt:n.value,loading:"lazy"},null,8,nt)):e.createCommentVNode("",!0)]),e.createElementVNode("div",st,[e.createElementVNode("p",rt,e.toDisplayString(n.value),1),s.value!==""?(e.openBlock(),e.createElementBlock("p",ct,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)])],64))}}),at={key:0,class:"dialog-search-card-body"},lt=["href"],j=e.defineComponent({__name:"DialogSearchProductCard",props:{controller:{},hit:{},index:{},locale:{}},setup(o){const t=o,n=e.ref();e.watch(()=>t.hit,()=>{n.value!==void 0&&t.controller.observeResult(n.value,t.index)},{immediate:!0,flush:"post"});const s=c=>{const a=c.metaKey||c.ctrlKey||c.shiftKey||c.altKey;t.controller.selectResult(t.index,{navigate:!a})&&c.preventDefault()},l=c=>{c.button===1&&t.controller.selectResult(t.index,{navigate:!1})},r=e.computed(()=>t.hit.url===void 0?void 0:tt(t.hit.url));return(c,a)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"cardRef",ref:n,class:"dialog-search-card"},[r.value===void 0?(e.openBlock(),e.createElementBlock("div",at,[e.createVNode(F,{hit:t.hit,locale:t.locale},null,8,["hit","locale"])])):(e.openBlock(),e.createElementBlock("a",{key:1,class:"dialog-search-card-body",href:r.value,onClick:s,onAuxclick:l},[e.createVNode(F,{hit:t.hit,locale:t.locale},null,8,["hit","locale"])],40,lt))],512))}}),it=o=>{const t=e.ref(),n=e.ref(void 0),s=e.ref(0);return e.watch(o,(l,r,c)=>{if(!l)return;const a=()=>{const d=t.value;if(d===void 0)return;const _=d.previousElementSibling??d,{top:u,bottom:p,left:g,width:C}=_.getBoundingClientRect();s.value=window.innerHeight;const i=n.value;(i===void 0||i.top!==u||i.bottom!==p||i.left!==g||i.width!==C)&&(n.value={top:u,bottom:p,left:g,width:C})};a(),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),c(()=>{window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)})},{immediate:!0,flush:"post"}),{anchorRef:t,rect:n,viewportHeight:s}},dt=(o,t)=>{const n=e.ref(!1),s=e.ref(),l=e.computed(()=>o.value.status!==y.IDLE&&!n.value);e.watch(()=>o.value.query,()=>{n.value=!1}),e.watch(l,(c,a,d)=>{if(!c)return;const _=u=>{var k,b;const p=u.target;if(!(p instanceof Node))return;const g=(k=t.value)==null?void 0:k.previousElementSibling,C=((b=s.value)==null?void 0:b.contains(p))??!1,i=(g==null?void 0:g.contains(p))??!1;!C&&!i&&(n.value=!0)};document.addEventListener("pointerdown",_),d(()=>document.removeEventListener("pointerdown",_))},{immediate:!0});const r=()=>{n.value=!1};return e.onMounted(()=>{var c,a;(a=(c=t.value)==null?void 0:c.previousElementSibling)==null||a.addEventListener("focusin",r)}),e.onUnmounted(()=>{var c,a;(a=(c=t.value)==null?void 0:c.previousElementSibling)==null||a.removeEventListener("focusin",r)}),{isOpen:l,panelRef:s}},ut={key:0,role:"status",class:"dialog-search-status"},pt={key:1,class:"dialog-search-error"},_t={role:"alert",class:"dialog-search-status dialog-search-status-error"},mt={key:2,role:"status",class:"dialog-search-status"},ht={role:"status",class:"dialog-search-status"},ft={class:"dialog-search-results"},D=8,G=16,gt=200,Et=e.defineComponent({__name:"DialogSearchResults",props:{controller:{},state:{},locale:{}},setup(o){const t=o,n=i=>i instanceof Y?`Search failed (${i.status}${i.code?` ${i.code}`:""}): ${i.message}`:"Search failed: network error. Check your connection and try again.",s=(i,k)=>i.bottom>0&&i.top<k,l=(i,k)=>{const b=k-i.bottom-D-G,w=i.top-D-G,m={left:`${i.left}px`,width:`${i.width}px`};return b<gt&&w>b?{...m,bottom:`${k-i.top+D}px`,maxHeight:`${Math.max(w,0)}px`}:{...m,top:`${i.bottom+D}px`,maxHeight:`${Math.max(b,0)}px`}},r=e.computed(()=>t.state),c=e.computed(()=>t.state.status!==y.IDLE),{anchorRef:a,rect:d,viewportHeight:_}=it(c),{isOpen:u,panelRef:p}=dt(r,a),g=e.computed(()=>u.value&&d.value!==void 0&&s(d.value,_.value)),C=e.computed(()=>d.value===void 0?void 0:l(d.value,_.value));return(i,k)=>{var b;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{ref_key:"anchorRef",ref:a},null,512),g.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[e.createElementVNode("div",{ref_key:"panelRef",ref:p,class:"dialog-search-panel",style:e.normalizeStyle(C.value)},[t.state.status===e.unref(y).LOADING?(e.openBlock(),e.createElementBlock("p",ut," Searching “"+e.toDisplayString(t.state.query)+"”… ",1)):t.state.status===e.unref(y).ERROR?(e.openBlock(),e.createElementBlock("div",pt,[e.createElementVNode("p",_t,e.toDisplayString(n(t.state.error)),1),e.createElementVNode("button",{type:"button",class:"dialog-search-retry",onClick:k[0]||(k[0]=w=>t.controller.retry())}," Retry ")])):t.state.status===e.unref(y).EMPTY?(e.openBlock(),e.createElementBlock("p",mt," No products match “"+e.toDisplayString((b=t.state.response)==null?void 0:b.query)+"”. ",1)):t.state.status===e.unref(y).SUCCESS&&t.state.response!==void 0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("p",ht,e.toDisplayString(t.state.response.nbHits)+" result"+e.toDisplayString(t.state.response.nbHits>1?"s":""),1),e.createElementVNode("ul",ft,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.state.response.hits,(w,m)=>(e.openBlock(),e.createBlock(j,{key:w.objectID,controller:t.controller,hit:w,index:m,locale:t.locale},null,8,["controller","hit","index","locale"]))),128))]),e.createVNode(K,{controller:t.controller,state:t.state},null,8,["controller","state"])],64)):e.createCommentVNode("",!0)],4)])):e.createCommentVNode("",!0)],64)}}}),St=o=>{const{client:t,surface:n="search_page",locale:s=t.locale,...l}=o,r=de({search:(d,_)=>t.search(d,_),locale:s,analytics:{surface:n,trackViewSearchResults:d=>t.trackViewSearchResults(d),trackSelectSearchResult:d=>t.trackSelectSearchResult(d)},...l}),c=e.shallowRef(r.getState()),a=r.subscribe(()=>{c.value=r.getState()});return e.onMounted(()=>{M({method:"vue",version:"3.5.0"})}),e.onUnmounted(()=>{a(),r.dispose()}),{controller:r,state:c}};S.DialogInput=H,S.DialogProductBlock=Oe,S.DialogSearchBar=Ye,S.DialogSearchPagination=K,S.DialogSearchProductCard=j,S.DialogSearchResults=Et,S.useDialogSearch=St,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askdialog/dialog-vue",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.5.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/dialog-vue.umd.js",
|
|
7
7
|
"module": "./dist/dialog-vue.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"eslint-plugin-vue": "^10.0.0",
|
|
30
30
|
"vite-plugin-eslint": "^1.8.1",
|
|
31
31
|
"vue-tsc": "^2.2.4",
|
|
32
|
-
"@askdialog/dialog-sdk": "2.
|
|
32
|
+
"@askdialog/dialog-sdk": "2.10.0"
|
|
33
33
|
},
|
|
34
34
|
"author": "Dialog",
|
|
35
35
|
"publishConfig": {
|