@askdialog/dialog-vue 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DialogSearch/DialogSearchBar.vue.d.ts +13 -0
- package/dist/components/DialogSearch/DialogSearchPagination.vue.d.ts +7 -0
- package/dist/components/DialogSearch/DialogSearchProductCard.vue.d.ts +10 -0
- package/dist/components/DialogSearch/DialogSearchProductCardContent.vue.d.ts +6 -0
- package/dist/components/DialogSearch/DialogSearchResults.vue.d.ts +10 -0
- package/dist/components/DialogSearch/searchDisplay.d.ts +3 -0
- package/dist/components/DialogSearch/useAnchorRect.d.ts +12 -0
- package/dist/components/DialogSearch/useDialogSearch.d.ts +17 -0
- package/dist/components/DialogSearch/useOutsideDismiss.d.ts +6 -0
- package/dist/components/index.d.ts +6 -1
- package/dist/dialog-vue.css +1 -1
- package/dist/dialog-vue.js +726 -139
- package/dist/dialog-vue.umd.cjs +3 -3
- package/dist/icons/ArrowUpIcon.vue.d.ts +2 -0
- package/dist/icons/ShurikenIcon.vue.d.ts +5 -0
- 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 _t=Object.defineProperty;var mt=(g,e,R)=>e in g?_t(g,e,{enumerable:!0,configurable:!0,writable:!0,value:R}):g[e]=R;var D=(g,e,R)=>mt(g,typeof e!="symbol"?e+"":e,R);const R=new Set(["ar","he","iw","fa","ur"]),K=o=>o!==void 0&&R.has(o.trim().toLowerCase().slice(0,2)),F=o=>K(o)?"rtl":"ltr";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 A;(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"})(A||(A={})),N.TRACK_ADD_TO_CART,N.TRACK_SUBMIT_CHECKOUT,N.TRACK_VIEW_SEARCH_RESULTS,N.TRACK_SELECT_SEARCH_RESULT;class G extends Error{constructor({status:n,code:s,message:i}){super(i);D(this,"status");D(this,"code");this.name="DialogSearchError",this.status=n,this.code=s}}const L="multiple installation methods detected:",j=()=>typeof window>"u"?void 0:window,V=()=>{const o=j();if(o!==void 0)return o.dialog=o.dialog??{},o.dialog.audit=o.dialog.audit??{methods:[],context:{},capabilities:[],warnings:[]},o.dialog.audit},Q=o=>{if(o.warnings=o.warnings.filter(t=>!t.startsWith(L)),o.methods.length>=2){const t=o.methods.map(n=>n.method).join(", ");o.warnings.push(`${L} ${t}`)}},W=(o,t)=>t===void 0?o:{version:(o==null?void 0:o.version)??t.version,commit:(o==null?void 0:o.commit)??t.commit},$=o=>{const t=V();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()}),Q(t);return}n.version=n.version??o.version,n.build=W(n.build,o.build),n.source=n.source??o.source},Y=o=>{const t=V();t!==void 0&&(t.capabilities.includes(o)||t.capabilities.push(o))},b={IDLE:"idle",LOADING:"loading",SUCCESS:"success",EMPTY:"empty",ERROR:"error"},z=.5,X=500,v=1500,Z=100;function J({emit:o,visibilityThreshold:t=z,dwellMs:n=X,idleFlushMs:s=v,maxItemsPerEvent:i=Z}){let r,c=[];const a=new Set,h=new Map,_=new Map;let u;const m=()=>{clearTimeout(u),!(r===void 0||c.length===0)&&(o({...r,items:c}),c=[])},f=l=>{if(r===void 0)return;const d=`${r.query_id}:${l.product_id}`;if(!a.has(d)){if(a.add(d),c.push(l),c.length>=i){m();return}clearTimeout(u),u=setTimeout(m,s)}},S=l=>{const d=_.get(l);d!==void 0&&(clearTimeout(d),_.delete(l))},p=new IntersectionObserver(l=>{for(const d of l){const C=h.get(d.target);C!==void 0&&(d.intersectionRatio>=t?_.has(d.target)||_.set(d.target,setTimeout(()=>{_.delete(d.target),f(C)},n)):S(d.target))}},{threshold:t}),k=()=>{p.disconnect();for(const l of _.values())clearTimeout(l);_.clear(),h.clear()},E=()=>{m()},y=l=>{if(l.persisted){a.clear();for(const d of h.keys())S(d),p.unobserve(d),p.observe(d)}};return window.addEventListener("pagehide",E),window.addEventListener("pageshow",y),{setContext(l){m(),r!==void 0&&r.query_id!==l.query_id&&a.clear(),r=l,k()},observe(l,d){h.set(l,d),p.observe(l)},forceImpression(l){f(l),m()},flush:m,disconnect(){m(),k(),window.removeEventListener("pagehide",E),window.removeEventListener("pageshow",y)}}}const P=(o,t)=>({product_id:o.hits[t].product.id,position:o.page*o.hitsPerPage+t+1});function ee(o){let t,n;const s=()=>(t??(t=J({emit:o.trackViewSearchResults})),t);return{onResponse(i){n={query_id:i.queryId,surface:o.surface,page:i.page+1,total_hits:i.nbHits,query_length:[...i.query].length},s().setContext(n),i.nbHits===0&&o.trackViewSearchResults({...n,items:[]})},observeResult(i,r,c){s().observe(i,P(r,c))},select(i,r){if(n===void 0)return;const c=P(i,r);s().forceImpression(c),o.trackSelectSearchResult({...n,items:[c]})},dispose(){t==null||t.disconnect()}}}const te=250,oe=12,ne=2,O={status:b.IDLE,query:"",page:0,response:void 0,error:void 0};function re({search:o,analytics:t,navigate:n,debounceMs:s=te,hitsPerPage:i=oe}){let r=O;const c=new Set,a=ee(t);let h,_,u,m=0,f=!1;const S=l=>{r={...r,...l};for(const d of c)d(r)},p=()=>{clearTimeout(h),u==null||u.abort(),u=void 0},k=(l,d)=>{const C={query:l,page:d,hitsPerPage:i},T=r.response;return(T==null?void 0:T.query)===l&&(C.queryId=T.queryId),C},E=async(l,d)=>{p(),u=new AbortController;const C=++m,T=k(l,d);S({status:b.LOADING,query:l,page:d});try{const w=await o(T,{signal:u.signal});if(C!==m)return;a.onResponse(w),S({status:w.nbHits===0?b.EMPTY:b.SUCCESS,response:w,error:void 0})}catch(w){if(w instanceof DOMException&&w.name==="AbortError"||C!==m)return;S({status:b.ERROR,error:w,response:void 0})}},y=l=>{const d=l.trim();if(p(),_=void 0,[...d].length<ne){m+=1,S(O);return}return d};return{setQuery(l){const d=f?void 0:y(l);d!==void 0&&(_=d,h=setTimeout(()=>{_=void 0,E(d,0)},s))},submit(l){const d=f?void 0:y(l);d!==void 0&&E(d,0)},setPage(l){if(!f){if(_!==void 0){const d=_;_=void 0,E(d,0);return}r.query!==""&&E(r.query,l)}},retry(){f||r.status!==b.ERROR||E(r.query,r.page)},observeResult(l,d){r.response!==void 0&&a.observeResult(l,r.response,d)},selectResult(l,d){const C=r.response;if(C===void 0)return!1;a.select(C,l);const T=C.hits[l].product.url;return((d==null?void 0:d.navigate)??!0)&&n!==void 0&&T!==void 0?(n(T,C.hits[l]),!0):!1},subscribe(l){return c.add(l),()=>{c.delete(l)}},getState:()=>r,dispose(){f=!0,p(),m+=1,_=void 0,c.clear(),a.dispose()}}}const se={class:"dialog-block-header-container"},ce={class:"dialog-block-title"},ie={class:"dialog-block-description"},ae=e.defineComponent({__name:"DialogBlockHeader",props:{title:{},description:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("div",se,[e.createElementVNode("div",ce,e.toDisplayString(t.title??"Your expert"),1),e.createElementVNode("div",ie,e.toDisplayString(t.description??"A question about this product?"),1)]))}}),I=(o,t)=>{const n=o.__vccOpts||o;for(const[s,i]of t)n[s]=i;return n},le=I(ae,[["__scopeId","data-v-28e6dda7"]]),de={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ue={"clip-path":"url(#clip0_466_934)"},pe=["stroke"],_e=["stroke"],me=e.defineComponent({__name:"AiStarsIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",de,[e.createElementVNode("g",ue,[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,pe),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,K)]),i[0]||(i[0]=e.createElementVNode("defs",null,[e.createElementVNode("clipPath",{id:"clip0_466_934"},[e.createElementVNode("rect",{width:"20",height:"20",fill:"white"})])],-1))]))}}),M=["onClick"],q={class:"dialog-block-suggestions-item-label"},x=m(e.defineComponent({__name:"DialogBlockSuggestions",props:{client:{},questions:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=i=>{t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:i,fromQuestionSuggestion:!0})};return(i,d)=>(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:l=>n(c.question)},[e.createVNode(P,{class:"dialog-block-suggestions-item-icon",color:t.client.theme.primaryColor},null,8,["color"]),e.createElementVNode("span",q,e.toDisplayString(c.question),1)],8,M))),128))}}),[["__scopeId","data-v-db34d4b4"]]),H={};function F(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 j=m(H,[["render",F],["__scopeId","data-v-26a64b58"]]),G={class:"dialog-block-suggestions-container"},Q=m(e.defineComponent({__name:"DialogBlockSuggestionsContainer",props:{client:{},questions:{},isLoading:{type:Boolean},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o;return(n,i)=>(e.openBlock(),e.createElementBlock("div",G,[t.isLoading||!t.questions?(e.openBlock(),e.createBlock(j,{key:0})):(e.openBlock(),e.createBlock(x,{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"]]),W={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Z=["stroke"],z=e.defineComponent({__name:"ArrowIcon",props:{color:{}},setup(o){const t=o;return(n,i)=>(e.openBlock(),e.createElementBlock("svg",W,[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,Z)]))}}),X=["placeholder"],Y=["disabled"],k=m(e.defineComponent({__name:"DialogInput",props:{client:{},placeholder:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=e.ref(),i=e.ref(""),d=()=>{var l;(l=n.value)==null||l.focus()},c=()=>{const l=i.value;l.trim()&&(t.client.sendProductMessage({productId:t.productId,productTitle:t.productTitle,selectedVariantId:t.selectedVariantId,question:l,fromQuestionSuggestion:!0}),i.value="")};return(l,r)=>(e.openBlock(),e.createElementBlock("div",{class:"dialog-input-wrapper",onClick:d},[e.withDirectives(e.createElementVNode("input",{id:"dialog-ask-anything-input-ai-input",ref_key:"inputRef",ref:n,"onUpdate:modelValue":r[0]||(r[0]=u=>i.value=u),class:"dialog-ask-anything-input-ai-input",placeholder:t.placeholder??"Ask anything...",onKeydown:e.withKeys(c,["enter"])},null,40,X),[[e.vModelText,i.value]]),e.createElementVNode("button",{id:"send-message-button-ai-input",class:"dialog-input-submit",disabled:!i.value.trim(),onClick:c},[e.createVNode(z,{color:t.client.theme.ctaTextColor},null,8,["color"])],8,Y)]))}}),[["__scopeId","data-v-4f5901c9"]]),J=e.defineComponent({__name:"ThemeProvider",props:{theme:{}},setup(o){const t=o,n=document.body,i=c=>c.replace(/([A-Z])/g,"-$1").toLowerCase(),d=c=>{c&&Object.keys(c).forEach(l=>{const r=l,u=i(l);if(c[r]!==void 0){if(typeof c[r]=="object"){Object.keys(c[r]).forEach(g=>{var p;const s=g;if(s!==void 0){const f=i(g),te=c[r];n.style.setProperty(`--dialog-theme-${u}-${f}`,(p=te[s])==null?void 0:p.toString())}});return}if(r==="ctaBorderType"){const g=c[r]==="rounded"?"24px":"0";n.style.setProperty(`--dialog-theme-${u}`,g);return}n.style.setProperty(`--dialog-theme-${u}`,c[r].toString())}})};return e.onMounted(()=>{t.theme&&d(t.theme)}),e.watch(()=>t.theme,c=>{c&&d(c)},{deep:!0}),(c,l)=>e.renderSlot(c.$slots,"default")}}),v=["dir"],ee=m(e.defineComponent({__name:"DialogProductBlock",props:{client:{},productId:{},productTitle:{},selectedVariantId:{default:void 0},enableInput:{type:Boolean,default:!0}},setup(o){const t=o;e.onMounted(()=>{N({method:"vue",version:"3.2.0"}),B("pdp-block")});const n=e.ref(!0),i=e.ref(void 0),d=e.ref(0),c=e.computed(()=>{var s;return n.value?"":(s=i.value)==null?void 0:s.assistantName}),l=e.computed(()=>{var s;return n.value?"":(s=i.value)==null?void 0:s.description}),r=e.computed(()=>{var s;return n.value?"":(s=i.value)==null?void 0:s.inputPlaceholder}),u=e.computed(()=>{var s;return I((s=t.client.getLocalizationInformations())==null?void 0:s.languageCode)}),g=async()=>{const s=++d.value;n.value=!0,i.value=void 0;try{const p=await t.client.getSuggestions(t.productId);s===d.value&&(i.value=p)}catch(p){console.error("error",p)}finally{s===d.value&&(n.value=!1)}};return e.watch(()=>[t.client,t.productId],()=>{g()},{immediate:!0}),(s,p)=>(e.openBlock(),e.createBlock(J,{theme:t.client.theme},{default:e.withCtx(()=>{var f;return[e.createElementVNode("div",{id:"dialog-instant",class:"dialog-block-container",dir:u.value},[e.createVNode(y,{title:c.value,description:l.value},null,8,["title","description"]),e.createVNode(Q,{client:t.client,questions:(f=i.value)==null?void 0:f.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(k,{key:0,client:t.client,placeholder:r.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,v)]}),_:1},8,["theme"]))}}),[["__scopeId","data-v-c57aa677"]]);a.DialogInput=k,a.DialogProductBlock=ee,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
19
|
+
1.66666Z`,stroke:t.color||"#181825","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,8,_e)]),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))]))}}),he=["onClick"],fe={class:"dialog-block-suggestions-item-label"},ge=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,i)=>(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(me,{class:"dialog-block-suggestions-item-icon",color:t.client.theme.primaryColor},null,8,["color"]),e.createElementVNode("span",fe,e.toDisplayString(r.question),1)],8,he))),128))}}),[["__scopeId","data-v-db34d4b4"]]),Ee={};function Se(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 ke=I(Ee,[["render",Se],["__scopeId","data-v-26a64b58"]]),Ce={class:"dialog-block-suggestions-container"},be=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",Ce,[t.isLoading||!t.questions?(e.openBlock(),e.createBlock(ke,{key:0})):(e.openBlock(),e.createBlock(ge,{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"]]),ye={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Te=["stroke"],we=e.defineComponent({__name:"ArrowIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",ye,[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,Te)]))}}),Ie=["placeholder"],Re=["disabled"],U=I(e.defineComponent({__name:"DialogInput",props:{client:{},placeholder:{},productId:{},productTitle:{},selectedVariantId:{}},setup(o){const t=o,n=e.ref(),s=e.ref(""),i=()=>{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:i},[e.withDirectives(e.createElementVNode("input",{id:"dialog-ask-anything-input-ai-input",ref_key:"inputRef",ref:n,"onUpdate:modelValue":a[0]||(a[0]=h=>s.value=h),class:"dialog-ask-anything-input-ai-input",placeholder:t.placeholder??"Ask anything...",onKeydown:e.withKeys(r,["enter"])},null,40,Ie),[[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(we,{color:t.client.theme.ctaTextColor},null,8,["color"])],8,Re)]))}}),[["__scopeId","data-v-4f5901c9"]]),Ne=e.defineComponent({__name:"ThemeProvider",props:{theme:{}},setup(o){const t=o,n=document.body,s=r=>r.replace(/([A-Z])/g,"-$1").toLowerCase(),i=r=>{r&&Object.keys(r).forEach(c=>{const a=c,h=s(c);if(r[a]!==void 0){if(typeof r[a]=="object"){Object.keys(r[a]).forEach(_=>{var m;const u=_;if(u!==void 0){const f=s(_),S=r[a];n.style.setProperty(`--dialog-theme-${h}-${f}`,(m=S[u])==null?void 0:m.toString())}});return}if(a==="ctaBorderType"){const _=r[a]==="rounded"?"24px":"0";n.style.setProperty(`--dialog-theme-${h}`,_);return}n.style.setProperty(`--dialog-theme-${h}`,r[a].toString())}})};return e.onMounted(()=>{t.theme&&i(t.theme)}),e.watch(()=>t.theme,r=>{r&&i(r)},{deep:!0}),(r,c)=>e.renderSlot(r.$slots,"default")}}),Be=["dir"],De=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(()=>{$({method:"vue",version:"3.3.0"}),Y("pdp-block")});const n=e.ref(!0),s=e.ref(void 0),i=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}),h=e.computed(()=>{var u;return F((u=t.client.getLocalizationInformations())==null?void 0:u.languageCode)}),_=async()=>{const u=++i.value;n.value=!0,s.value=void 0;try{const m=await t.client.getSuggestions(t.productId);u===i.value&&(s.value=m)}catch(m){console.error("error",m)}finally{u===i.value&&(n.value=!1)}};return e.watch(()=>[t.client,t.productId],()=>{_()},{immediate:!0}),(u,m)=>(e.openBlock(),e.createBlock(Ne,{theme:t.client.theme},{default:e.withCtx(()=>{var f;return[e.createElementVNode("div",{id:"dialog-instant",class:"dialog-block-container",dir:h.value},[e.createVNode(le,{title:r.value,description:c.value},null,8,["title","description"]),e.createVNode(be,{client:t.client,questions:(f=s.value)==null?void 0:f.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(U,{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,Be)]}),_:1},8,["theme"]))}}),[["__scopeId","data-v-c57aa677"]]),Ae={},Le={width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"};function Ve(o,t){return e.openBlock(),e.createElementBlock("svg",Le,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 $e=I(Ae,[["render",Ve]]),Pe={width:"16",height:"16",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},Oe=["fill"],Ue="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",Me=e.defineComponent({__name:"ShurikenIcon",props:{color:{}},setup(o){const t=o;return(n,s)=>(e.openBlock(),e.createElementBlock("svg",Pe,[e.createElementVNode("path",{d:Ue,fill:t.color||"currentColor"},null,8,Oe)]))}}),qe={class:"dialog-search-bar-field"},xe={class:"dialog-search-bar-icon"},He=["aria-label","placeholder","autofocus"],Ke=["aria-label"],Fe=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)},i=()=>{t.controller.submit(n.value)};return(r,c)=>(e.openBlock(),e.createElementBlock("form",{class:"dialog-search-bar",role:"search",onSubmit:e.withModifiers(i,["prevent"])},[e.createElementVNode("div",qe,[e.createElementVNode("span",xe,[e.createVNode(Me)]),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,He),[[e.vModelText,n.value]])]),e.createElementVNode("button",{type:"submit",class:"dialog-search-bar-submit","aria-label":t.submitAriaLabel},[e.createVNode($e)],8,Ke)],32))}}),Ge={key:0,"aria-label":"Search results pages",class:"dialog-search-pagination"},je=["disabled"],Qe=["disabled"],M=e.defineComponent({__name:"DialogSearchPagination",props:{controller:{},state:{}},setup(o){const t=o,n=e.computed(()=>t.state.response);return(s,i)=>n.value!==void 0&&n.value.nbPages>1?(e.openBlock(),e.createElementBlock("nav",Ge,[e.createElementVNode("button",{type:"button",disabled:n.value.page===0,onClick:i[0]||(i[0]=r=>t.controller.setPage(n.value.page-1))}," Previous ",8,je),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]=r=>t.controller.setPage(n.value.page+1))}," Next ",8,Qe)])):e.createCommentVNode("",!0)}}),We=o=>{if(o===void 0)return"";const{min:t,max:n}=o,s=({amount:i,currencyCode:r})=>new Intl.NumberFormat(void 0,{style:"currency",currency:r}).format(Number(i));try{return t.amount===n.amount?s(t):`${s(t)} – ${s(n)}`}catch{return""}},Ye=o=>{try{const{protocol:t}=new URL(o,window.location.href);return t==="http:"||t==="https:"?o:void 0}catch{return}},ze={class:"dialog-search-card-image"},Xe=["src","alt"],ve={class:"dialog-search-card-info"},Ze={class:"dialog-search-card-title"},Je={key:0,class:"dialog-search-card-price"},q=e.defineComponent({__name:"DialogSearchProductCardContent",props:{hit:{}},setup(o){const t=o,n=e.computed(()=>t.hit.product.title??t.hit.product.id),s=e.computed(()=>We(t.hit.product.priceRange));return(i,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ze,[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,Xe)):e.createCommentVNode("",!0)]),e.createElementVNode("div",ve,[e.createElementVNode("p",Ze,e.toDisplayString(n.value),1),s.value!==""?(e.openBlock(),e.createElementBlock("p",Je,e.toDisplayString(s.value),1)):e.createCommentVNode("",!0)])],64))}}),et={key:0,class:"dialog-search-card-body"},tt=["href"],x=e.defineComponent({__name:"DialogSearchProductCard",props:{controller:{},hit:{},index:{}},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()},i=c=>{c.button===1&&t.controller.selectResult(t.index,{navigate:!1})},r=e.computed(()=>t.hit.product.url===void 0?void 0:Ye(t.hit.product.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",et,[e.createVNode(q,{hit:t.hit},null,8,["hit"])])):(e.openBlock(),e.createElementBlock("a",{key:1,class:"dialog-search-card-body",href:r.value,onClick:s,onAuxclick:i},[e.createVNode(q,{hit:t.hit},null,8,["hit"])],40,tt))],512))}}),ot=o=>{const t=e.ref(),n=e.ref(void 0),s=e.ref(0);return e.watch(o,(i,r,c)=>{if(!i)return;const a=()=>{const h=t.value;if(h===void 0)return;const _=h.previousElementSibling??h,{top:u,bottom:m,left:f,width:S}=_.getBoundingClientRect();s.value=window.innerHeight;const p=n.value;(p===void 0||p.top!==u||p.bottom!==m||p.left!==f||p.width!==S)&&(n.value={top:u,bottom:m,left:f,width:S})};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}},nt=(o,t)=>{const n=e.ref(!1),s=e.ref(),i=e.computed(()=>o.value.status!==b.IDLE&&!n.value);e.watch(()=>o.value.query,()=>{n.value=!1}),e.watch(i,(c,a,h)=>{if(!c)return;const _=u=>{var k,E;const m=u.target;if(!(m instanceof Node))return;const f=(k=t.value)==null?void 0:k.previousElementSibling,S=((E=s.value)==null?void 0:E.contains(m))??!1,p=(f==null?void 0:f.contains(m))??!1;!S&&!p&&(n.value=!0)};document.addEventListener("pointerdown",_),h(()=>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:i,panelRef:s}},rt={key:0,role:"status",class:"dialog-search-status"},st={key:1,class:"dialog-search-error"},ct={role:"alert",class:"dialog-search-status dialog-search-status-error"},it={key:2,role:"status",class:"dialog-search-status"},at={role:"status",class:"dialog-search-status"},lt={class:"dialog-search-results"},B=8,H=16,dt=200,ut=e.defineComponent({__name:"DialogSearchResults",props:{controller:{},state:{}},setup(o){const t=o,n=p=>p instanceof G?`Search failed (${p.status}${p.code?` ${p.code}`:""}): ${p.message}`:"Search failed: network error. Check your connection and try again.",s=(p,k)=>p.bottom>0&&p.top<k,i=(p,k)=>{const E=k-p.bottom-B-H,y=p.top-B-H,l={left:`${p.left}px`,width:`${p.width}px`};return E<dt&&y>E?{...l,bottom:`${k-p.top+B}px`,maxHeight:`${Math.max(y,0)}px`}:{...l,top:`${p.bottom+B}px`,maxHeight:`${Math.max(E,0)}px`}},r=e.computed(()=>t.state),c=e.computed(()=>t.state.status!==b.IDLE),{anchorRef:a,rect:h,viewportHeight:_}=ot(c),{isOpen:u,panelRef:m}=nt(r,a),f=e.computed(()=>u.value&&h.value!==void 0&&s(h.value,_.value)),S=e.computed(()=>h.value===void 0?void 0:i(h.value,_.value));return(p,k)=>{var E;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{ref_key:"anchorRef",ref:a},null,512),f.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(S.value)},[t.state.status===e.unref(b).LOADING?(e.openBlock(),e.createElementBlock("p",rt," Searching “"+e.toDisplayString(t.state.query)+"”… ",1)):t.state.status===e.unref(b).ERROR?(e.openBlock(),e.createElementBlock("div",st,[e.createElementVNode("p",ct,e.toDisplayString(n(t.state.error)),1),e.createElementVNode("button",{type:"button",class:"dialog-search-retry",onClick:k[0]||(k[0]=y=>t.controller.retry())}," Retry ")])):t.state.status===e.unref(b).EMPTY?(e.openBlock(),e.createElementBlock("p",it," No products match “"+e.toDisplayString((E=t.state.response)==null?void 0:E.query)+"”. ",1)):t.state.status===e.unref(b).SUCCESS&&t.state.response!==void 0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("p",at,e.toDisplayString(t.state.response.nbHits)+" result"+e.toDisplayString(t.state.response.nbHits>1?"s":""),1),e.createElementVNode("ul",lt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.state.response.hits,(y,l)=>(e.openBlock(),e.createBlock(x,{key:y.id,controller:t.controller,hit:y,index:l},null,8,["controller","hit","index"]))),128))]),e.createVNode(M,{controller:t.controller,state:t.state},null,8,["controller","state"])],64)):e.createCommentVNode("",!0)],4)])):e.createCommentVNode("",!0)],64)}}}),pt=o=>{const{client:t,surface:n="search_page",...s}=o,i=re({search:(a,h)=>t.search(a,h),analytics:{surface:n,trackViewSearchResults:a=>t.trackViewSearchResults(a),trackSelectSearchResult:a=>t.trackSelectSearchResult(a)},...s}),r=e.shallowRef(i.getState()),c=i.subscribe(()=>{r.value=i.getState()});return e.onMounted(()=>{$({method:"vue",version:"3.3.0"})}),e.onUnmounted(()=>{c(),i.dispose()}),{controller:i,state:r}};g.DialogInput=U,g.DialogProductBlock=De,g.DialogSearchBar=Fe,g.DialogSearchPagination=M,g.DialogSearchProductCard=x,g.DialogSearchResults=ut,g.useDialogSearch=pt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, SVGSVGElement>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
color?: string;
|
|
3
|
+
};
|
|
4
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, SVGSVGElement>;
|
|
5
|
+
export default _default;
|
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.3.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.8.
|
|
32
|
+
"@askdialog/dialog-sdk": "2.8.1"
|
|
33
33
|
},
|
|
34
34
|
"author": "Dialog",
|
|
35
35
|
"publishConfig": {
|