@pairbo/ui-kit 0.4.1 → 0.4.2
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/ui-kit.js +1 -1
- package/package.json +1 -1
package/dist/ui-kit.js
CHANGED
|
@@ -1484,7 +1484,7 @@
|
|
|
1484
1484
|
.skip::part(label) {
|
|
1485
1485
|
font-size: 14px;
|
|
1486
1486
|
}
|
|
1487
|
-
`,bi=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),Es=n=>n!=null,hc=n=>Object.entries(n).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function ip(n,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>n.apply(this,i),t)}}const dc=(n,t)=>Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2));var sp=Object.defineProperty,rp=Object.getOwnPropertyDescriptor,mt=(n,t,e,i)=>{for(var s=i>1?void 0:i?rp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&sp(t,e,s),s};let J=class extends vt{constructor(){super(...arguments),this.resizeTimeout=null,this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.submitTypeForm=async t=>{console.error("submitTypingForm function not implemented",t)},this.loading=!1,this.disabled=!1,this.onClose=()=>{},this.ctaButtonPrimaryLabel="Add to Cart",this.CTA_STATES={danger:{type:"danger",message:"Add a message
|
|
1487
|
+
`,bi=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),Es=n=>n!=null,hc=n=>Object.entries(n).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function ip(n,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>n.apply(this,i),t)}}const dc=(n,t)=>Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2));var sp=Object.defineProperty,rp=Object.getOwnPropertyDescriptor,mt=(n,t,e,i)=>{for(var s=i>1?void 0:i?rp(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&sp(t,e,s),s};let J=class extends vt{constructor(){super(...arguments),this.resizeTimeout=null,this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.submitTypeForm=async t=>{console.error("submitTypingForm function not implemented",t)},this.loading=!1,this.disabled=!1,this.onClose=()=>{},this.ctaButtonPrimaryLabel="Add to Cart",this.CTA_STATES={danger:{type:"danger",message:"Add a message"},primary:{type:"primary",message:this.ctaButtonPrimaryLabel}},this.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=this.CTA_STATES.primary,this.wrappedSubmitTypeForm=async t=>{console.warn("submitTypingForm function not implemented",t)},this.processedMessage="",this.maxChars=223,this.handleTypeCanvasProcessed=t=>{const e=t;this.processedMessage=e.detail.message},this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}handleCardChange(){this.card&&(this.card.hasEditorial===void 0&&(this.maxChars=223),this.maxChars=this.card.hasEditorial?223:600)}updateWrappedSubmitTypeForm(){this.wrappedSubmitTypeForm=async t=>{this.loading=!0,this.disabled=!0;try{this.submitTypeForm(t),this.onClose(),this.emit("pbo-type-form-submitted")}catch(e){console.error("Error submitting type form:",e)}finally{this.loading=!1,this.disabled=!1}}}firstUpdated(){this.textarea.addEventListener("invalid",()=>{alert("Please add a message to continue")}),this.CTA_STATES.primary.message=this.ctaButtonPrimaryLabel}get formData(){var e,i,s,r,o,a,l,c,h;const t={pboCardId:((e=this.card)==null?void 0:e.pboId)||"Unknown",productId:(i=this.card)==null?void 0:i.productId,barcode:(s=this.card)==null?void 0:s.barcode,sku:(r=this.card)==null?void 0:r.sku,variantId:(o=this.card)==null?void 0:o.variantId,font:((a=this.fontSelector)==null?void 0:a.value)||"",text:((l=this.textarea)==null?void 0:l.value)||"",processedMessage:this.processedMessage,color:((c=this.textColor)==null?void 0:c.value)||"",alignment:((h=this.textAlignment)==null?void 0:h.value)||""};return hc(t)}handleFormChange(t){var e;this.ctaButtonState=this.CTA_STATES.primary,this.charsNum=((e=this.textarea)==null?void 0:e.value.length)||0,this.emit("pbo-type-form-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var i;t.preventDefault();const e=(i=t.submitter)==null?void 0:i.name;if(this.ctaButtonState.type==="danger"){e==="skip"&&this.wrappedSubmitTypeForm(this.formData);return}if(this.textarea.value===""||this.textarea.value===null||this.textarea.value===void 0){this.ctaButtonState=this.CTA_STATES.danger,this.textarea.focus();return}this.wrappedSubmitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize),window.addEventListener("pbo-type-canvas-processed",this.handleTypeCanvasProcessed)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),window.removeEventListener("pbo-type-canvas-processed",this.handleTypeCanvasProcessed),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=this.maxChars-this.charsNum;return j`
|
|
1488
1488
|
<form class="typing-form" @submit=${this.submitFormHandler}>
|
|
1489
1489
|
<pbo-textarea
|
|
1490
1490
|
exportparts="textarea:editor-textarea"
|