@askdialog/dialog-vue 3.5.0 → 3.6.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/README.md +8 -6
- package/dist/components/DialogSearch/useDialogSearch.d.ts +7 -5
- package/dist/dialog-vue.js +462 -432
- package/dist/dialog-vue.umd.cjs +2 -2
- package/package.json +2 -2
package/dist/dialog-vue.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g["dialog-vue"]={},g.Vue))})(this,(function(g,e){"use strict";var Ct=Object.defineProperty;var bt=(g,e,N)=>e in g?Ct(g,e,{enumerable:!0,configurable:!0,writable:!0,value:N}):g[e]=N;var P=(g,e,N)=>bt(g,typeof e!="symbol"?e+"":e,N);const N=new Set(["ar","he","iw","fa","ur"]),W=o=>o!==void 0&&N.has(o.trim().toLowerCase().slice(0,2)),v=o=>W(o)?"rtl":"ltr";var B;(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"})(B||(B={}));var O;(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"})(O||(O={})),B.TRACK_ADD_TO_CART,B.TRACK_SUBMIT_CHECKOUT,B.TRACK_VIEW_SEARCH_RESULTS,B.TRACK_SELECT_SEARCH_RESULT;class Y extends Error{constructor({status:n,code:s,message:a}){super(a);P(this,"status");P(this,"code");this.name="DialogSearchError",this.status=n,this.code=s}}const $=(o,t,n)=>{if(!/^[a-z]{2}$/.test(t))throw new Error("Search language must be a lowercase ISO 639-1 code.");if(!/^[A-Za-z]{3}$/.test(n))throw new Error("Search currency must be an ISO 4217 code.");return`${o}_${t}_${n.toLowerCase()}`},x="multiple installation methods detected:",X=()=>typeof window>"u"?void 0:window,M=()=>{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(x)),o.methods.length>=2){const t=o.methods.map(n=>n.method).join(", ");o.warnings.push(`${x} ${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},U=o=>{const t=M();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=M();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:a=se}){let c,r=[];const i=new Set,p=new Map,l=new Map;let d;const m=()=>{clearTimeout(d),!(c===void 0||r.length===0)&&(o({...c,items:r}),r=[])},E=h=>{if(c===void 0)return;const _=`${c.query_id}:${h.product_id}`;if(!i.has(_)){if(i.add(_),r.push(h),r.length>=a){m();return}clearTimeout(d),d=setTimeout(m,s)}},b=h=>{const _=l.get(h);_!==void 0&&(clearTimeout(_),l.delete(h))},u=new IntersectionObserver(h=>{for(const _ of h){const f=p.get(_.target);f!==void 0&&(_.intersectionRatio>=t?l.has(_.target)||l.set(_.target,setTimeout(()=>{l.delete(_.target),E(f)},n)):b(_.target))}},{threshold:t}),S=()=>{u.disconnect();for(const h of l.values())clearTimeout(h);l.clear(),p.clear()},k=()=>{m()},w=h=>{if(h.persisted){i.clear();for(const _ of p.keys())b(_),u.unobserve(_),u.observe(_)}};return window.addEventListener("pagehide",k),window.addEventListener("pageshow",w),{setContext(h){m(),i.clear(),c=h,S()},observe(h,_){p.set(h,_),u.observe(h)},forceImpression(h){E(h),m()},flush:m,disconnect(){m(),S(),window.removeEventListener("pagehide",k),window.removeEventListener("pageshow",w)}}}const q=(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(a){n={query_id:a.queryID,index:a.index,surface:o.surface,search_type:"lexical",page:a.page+1,total_hits:a.nbHits,query_length:[...a.query].length},s().setContext(n),a.nbHits===0&&o.trackViewSearchResults({...n,items:[]})},observeResult(a,c,r){s().observe(a,q(c,r))},select(a,c){if(n===void 0)return;const r=q(a,c);s().forceImpression(r),o.trackSelectSearchResult({...n,items:[r]})},dispose(){t==null||t.disconnect()}}}const ae=2,K=o=>{const t=o.trim();return[...t].length>=ae?t:void 0},ie=(o,t,n,{indexName:s,language:a,currency:c,hitsPerPage:r})=>({requests:[{indexName:s,query:o,page:t,hitsPerPage:r},...n.map(i=>({indexName:$(i.index,a,c),query:o,page:0,hitsPerPage:i.hitsPerPage??r}))]}),le=(o,t,{indexName:n,language:s,currency:a})=>{const c=o.results.find(i=>i.index===n);if(c===void 0)throw new Error(`Dialog search returned no ${n} entry`);const r={};for(const i of t){const p=$(i.index,s,a),l=o.results.find(d=>d.index===p);l!==void 0&&(r[i.index]=l)}return{response:c,sections:t.length===0?void 0:r}},L={status:y.IDLE,query:"",page:0,response:void 0,sections:void 0,error:void 0};function de({search:o,language:t,currency:n,analytics:s,navigate:a,debounceMs:c=250,hitsPerPage:r=12,sections:i=[]}){const p={indexName:$("products",t,n),language:t,currency:n,hitsPerPage:r};let l=L;const d=new Set,m=ce(s);let E,b,u,S=0,k=!1;const w=f=>{l={...l,...f};for(const C of d)C(l)},h=()=>{clearTimeout(E),b=void 0,S+=1,u==null||u.abort(),u=void 0},_=async(f,C)=>{h(),u=new AbortController;const R=S;w({status:y.LOADING,query:f,page:C});try{const I=typeof i=="function"?i():i,z=ie(f,C,I,p),kt=await o(z,{signal:u.signal});if(R!==S)return;const V=le(kt,I,p);m.onResponse(V.response),w({...V,status:V.response.nbHits===0?y.EMPTY:y.SUCCESS,error:void 0})}catch(I){if(I instanceof DOMException&&I.name==="AbortError"||R!==S)return;w({status:y.ERROR,error:I,response:void 0,sections:void 0})}};return{setQuery(f){if(k)return;h();const C=K(f);if(C===void 0){w(L);return}b=C,E=setTimeout(()=>void _(C,0),c)},submit(f){if(k)return;h();const C=K(f);if(C===void 0){w(L);return}_(C,0)},setPage(f){if(!k){if(b!==void 0){_(b,0);return}l.query!==""&&_(l.query,f)}},retry(){k||l.status!==y.ERROR||_(l.query,l.page)},observeResult(f,C){l.response!==void 0&&m.observeResult(f,l.response,C)},selectResult(f,C){const R=l.response;if(R===void 0)return!1;m.select(R,f);const I=R.hits[f].url;return((C==null?void 0:C.navigate)??!0)&&a!==void 0&&I!==void 0?(a(I,R.hits[f]),!0):!1},subscribe(f){return d.add(f),()=>{d.delete(f)}},getState:()=>l,dispose(){k=!0,h(),d.clear(),m.dispose()}}}const ue={class:"dialog-block-header-container"},pe={class:"dialog-block-title"},me={class:"dialog-block-description"},he=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",me,e.toDisplayString(t.description??"A question about this product?"),1)]))}}),T=(o,t)=>{const n=o.__vccOpts||o;for(const[s,a]of t)n[s]=a;return n},_e=T(he,[["__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
|
|
@@ -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,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"})}));
|
|
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"},we=T(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,a)=>(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:r=>n(c.question)},[e.createVNode(ke,{class:"dialog-block-suggestions-item-icon",color:t.client.theme.primaryColor},null,8,["color"]),e.createElementVNode("span",be,e.toDisplayString(c.question),1)],8,Ce))),128))}}),[["__scopeId","data-v-db34d4b4"]]),ye={};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=T(ye,[["render",Ie],["__scopeId","data-v-26a64b58"]]),Re={class:"dialog-block-suggestions-container"},Ne=T(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(we,{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"],$e=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)]))}}),Le=["placeholder"],Ae=["disabled"],H=T(e.defineComponent({__name:"DialogInput",props:{client:{},placeholder:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=e.ref(),s=e.ref(""),a=()=>{var r;(r=n.value)==null||r.focus()},c=()=>{const r=s.value;r.trim()&&(t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:r,fromQuestionSuggestion:!0}),s.value="")};return(r,i)=>(e.openBlock(),e.createElementBlock("div",{class:"dialog-input-wrapper",onClick:a},[e.withDirectives(e.createElementVNode("input",{id:"dialog-ask-anything-input-ai-input",ref_key:"inputRef",ref:n,"onUpdate:modelValue":i[0]||(i[0]=p=>s.value=p),class:"dialog-ask-anything-input-ai-input",placeholder:t.placeholder??"Ask anything...",onKeydown:e.withKeys(c,["enter"])},null,40,Le),[[e.vModelText,s.value]]),e.createElementVNode("button",{id:"send-message-button-ai-input",class:"dialog-input-submit",disabled:!s.value.trim(),onClick:c},[e.createVNode($e,{color:t.client.theme.ctaTextColor},null,8,["color"])],8,Ae)]))}}),[["__scopeId","data-v-4f5901c9"]]),Ve=e.defineComponent({__name:"ThemeProvider",props:{theme:{}},setup(o){const t=o,n=document.body,s=c=>c.replace(/([A-Z])/g,"-$1").toLowerCase(),a=c=>{c&&Object.keys(c).forEach(r=>{const i=r,p=s(r);if(c[i]!==void 0){if(typeof c[i]=="object"){Object.keys(c[i]).forEach(l=>{var m;const d=l;if(d!==void 0){const E=s(l),b=c[i];n.style.setProperty(`--dialog-theme-${p}-${E}`,(m=b[d])==null?void 0:m.toString())}});return}if(i==="ctaBorderType"){const l=c[i]==="rounded"?"24px":"0";n.style.setProperty(`--dialog-theme-${p}`,l);return}n.style.setProperty(`--dialog-theme-${p}`,c[i].toString())}})};return e.onMounted(()=>{t.theme&&a(t.theme)}),e.watch(()=>t.theme,c=>{c&&a(c)},{deep:!0}),(c,r)=>e.renderSlot(c.$slots,"default")}}),Pe=["dir"],Oe=T(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.6.0"}),ee("pdp-block")});const n=e.ref(!0),s=e.ref(void 0),a=e.ref(0),c=e.computed(()=>{var d;return n.value?"":(d=s.value)==null?void 0:d.assistantName}),r=e.computed(()=>{var d;return n.value?"":(d=s.value)==null?void 0:d.description}),i=e.computed(()=>{var d;return n.value?"":(d=s.value)==null?void 0:d.inputPlaceholder}),p=e.computed(()=>{var d;return v((d=t.client.getLocalizationInformations())==null?void 0:d.languageCode)}),l=async()=>{const d=++a.value;n.value=!0,s.value=void 0;try{const m=await t.client.getSuggestions(t.productId);d===a.value&&(s.value=m)}catch(m){console.error("error",m)}finally{d===a.value&&(n.value=!1)}};return e.watch(()=>[t.client,t.productId],()=>{l()},{immediate:!0}),(d,m)=>(e.openBlock(),e.createBlock(Ve,{theme:t.client.theme},{default:e.withCtx(()=>{var E;return[e.createElementVNode("div",{id:"dialog-instant",class:"dialog-block-container",dir:p.value},[e.createVNode(_e,{title:c.value,description:r.value},null,8,["title","description"]),e.createVNode(Ne,{client:t.client,questions:(E=s.value)==null?void 0:E.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:i.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"]]),xe={},Me={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",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=T(xe,[["render",Ue]]),Ke={width:"16",height:"16",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},He=["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",Ke,[e.createElementVNode("path",{d:Fe,fill:t.color||"currentColor"},null,8,He)]))}}),Ge={class:"dialog-search-bar-field"},Qe={class:"dialog-search-bar-icon"},ze=["aria-label","placeholder","autofocus"],We=["aria-label"],ve=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)},a=()=>{t.controller.submit(n.value)};return(c,r)=>(e.openBlock(),e.createElementBlock("form",{class:"dialog-search-bar",role:"search",onSubmit:e.withModifiers(a,["prevent"])},[e.createElementVNode("div",Ge,[e.createElementVNode("span",Qe,[e.createVNode(je)]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":r[0]||(r[0]=i=>n.value=i),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,ze),[[e.vModelText,n.value]])]),e.createElementVNode("button",{type:"submit",class:"dialog-search-bar-submit","aria-label":t.submitAriaLabel},[e.createVNode(qe)],8,We)],32))}}),Ye={key:0,"aria-label":"Search results pages",class:"dialog-search-pagination"},Xe=["disabled"],Ze=["disabled"],F=e.defineComponent({__name:"DialogSearchPagination",props:{controller:{},state:{}},setup(o){const t=o,n=e.computed(()=>t.state.response);return(s,a)=>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:a[0]||(a[0]=c=>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:a[1]||(a[1]=c=>t.controller.setPage(n.value.page+1))}," Next ",8,Ze)])):e.createCommentVNode("",!0)}}),A=({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?A(o,n):`${A(o,n)} – ${A(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"},j=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(a,c)=>(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"},it=["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 s=r=>{const i=r.metaKey||r.ctrlKey||r.shiftKey||r.altKey;t.controller.selectResult(t.index,{navigate:!i})&&r.preventDefault()},a=r=>{r.button===1&&t.controller.selectResult(t.index,{navigate:!1})},c=e.computed(()=>t.hit.url===void 0?void 0:tt(t.hit.url));return(r,i)=>(e.openBlock(),e.createElementBlock("li",{ref_key:"cardRef",ref:n,class:"dialog-search-card"},[c.value===void 0?(e.openBlock(),e.createElementBlock("div",at,[e.createVNode(j,{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:s,onAuxclick:a},[e.createVNode(j,{hit:t.hit,locale:t.locale},null,8,["hit","locale"])],40,it))],512))}}),lt=o=>{const t=e.ref(),n=e.ref(void 0),s=e.ref(0);return e.watch(o,(a,c,r)=>{if(!a)return;const i=()=>{const p=t.value;if(p===void 0)return;const l=p.previousElementSibling??p,{top:d,bottom:m,left:E,width:b}=l.getBoundingClientRect();s.value=window.innerHeight;const u=n.value;(u===void 0||u.top!==d||u.bottom!==m||u.left!==E||u.width!==b)&&(n.value={top:d,bottom:m,left:E,width:b})};i(),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),r(()=>{window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)})},{immediate:!0,flush:"post"}),{anchorRef:t,rect:n,viewportHeight:s}},dt=(o,t)=>{const n=e.ref(!1),s=e.ref(),a=e.computed(()=>o.value.status!==y.IDLE&&!n.value);e.watch(()=>o.value.query,()=>{n.value=!1}),e.watch(a,(r,i,p)=>{if(!r)return;const l=d=>{var S,k;const m=d.target;if(!(m instanceof Node))return;const E=(S=t.value)==null?void 0:S.previousElementSibling,b=((k=s.value)==null?void 0:k.contains(m))??!1,u=(E==null?void 0:E.contains(m))??!1;!b&&!u&&(n.value=!0)};document.addEventListener("pointerdown",l),p(()=>document.removeEventListener("pointerdown",l))},{immediate:!0});const c=()=>{n.value=!1};return e.onMounted(()=>{var r,i;(i=(r=t.value)==null?void 0:r.previousElementSibling)==null||i.addEventListener("focusin",c)}),e.onUnmounted(()=>{var r,i;(i=(r=t.value)==null?void 0:r.previousElementSibling)==null||i.removeEventListener("focusin",c)}),{isOpen:a,panelRef:s}},ut={key:0,role:"status",class:"dialog-search-status"},pt={key:1,class:"dialog-search-error"},mt={role:"alert",class:"dialog-search-status dialog-search-status-error"},ht={key:2,role:"status",class:"dialog-search-status"},_t={role:"status",class:"dialog-search-status"},ft={class:"dialog-search-results"},D=8,Q=16,gt=200,Et=e.defineComponent({__name:"DialogSearchResults",props:{controller:{},state:{},locale:{}},setup(o){const t=o,n=u=>u instanceof Y?`Search failed (${u.status}${u.code?` ${u.code}`:""}): ${u.message}`:"Search failed: network error. Check your connection and try again.",s=(u,S)=>u.bottom>0&&u.top<S,a=(u,S)=>{const k=S-u.bottom-D-Q,w=u.top-D-Q,h={left:`${u.left}px`,width:`${u.width}px`};return k<gt&&w>k?{...h,bottom:`${S-u.top+D}px`,maxHeight:`${Math.max(w,0)}px`}:{...h,top:`${u.bottom+D}px`,maxHeight:`${Math.max(k,0)}px`}},c=e.computed(()=>t.state),r=e.computed(()=>t.state.status!==y.IDLE),{anchorRef:i,rect:p,viewportHeight:l}=lt(r),{isOpen:d,panelRef:m}=dt(c,i),E=e.computed(()=>d.value&&p.value!==void 0&&s(p.value,l.value)),b=e.computed(()=>p.value===void 0?void 0:a(p.value,l.value));return(u,S)=>{var k;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{ref_key:"anchorRef",ref:i},null,512),E.value?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[e.createElementVNode("div",{ref_key:"panelRef",ref:m,class:"dialog-search-panel",style:e.normalizeStyle(b.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",mt,e.toDisplayString(n(t.state.error)),1),e.createElementVNode("button",{type:"button",class:"dialog-search-retry",onClick:S[0]||(S[0]=w=>t.controller.retry())}," Retry ")])):t.state.status===e.unref(y).EMPTY?(e.openBlock(),e.createElementBlock("p",ht," No products match “"+e.toDisplayString((k=t.state.response)==null?void 0:k.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",ft,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.state.response.hits,(w,h)=>(e.openBlock(),e.createBlock(G,{key:w.objectID,controller:t.controller,hit:w,index:h,locale:t.locale},null,8,["controller","hit","index","locale"]))),128))]),e.createVNode(F,{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",...s}=o,a=de({search:(i,p)=>t.search(i,p),analytics:{surface:n,trackViewSearchResults:i=>t.trackViewSearchResults(i),trackSelectSearchResult:i=>t.trackSelectSearchResult(i)},...s}),c=e.shallowRef(a.getState()),r=a.subscribe(()=>{c.value=a.getState()});return e.onMounted(()=>{U({method:"vue",version:"3.6.0"})}),e.onUnmounted(()=>{r(),a.dispose()}),{controller:a,state:c}};g.DialogInput=H,g.DialogProductBlock=Oe,g.DialogSearchBar=ve,g.DialogSearchPagination=F,g.DialogSearchProductCard=G,g.DialogSearchResults=Et,g.useDialogSearch=St,Object.defineProperty(g,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.6.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.12.0"
|
|
33
33
|
},
|
|
34
34
|
"author": "Dialog",
|
|
35
35
|
"publishConfig": {
|