@pairbo/ui-kit 0.3.28 → 0.3.29

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.
Files changed (2) hide show
  1. package/dist/ui-kit.js +2 -2
  2. package/package.json +1 -1
package/dist/ui-kit.js CHANGED
@@ -1475,7 +1475,7 @@
1475
1475
  .skip::part(label) {
1476
1476
  font-size: 14px;
1477
1477
  }
1478
- `,pi=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),ws=o=>o!=null,Kl=o=>Object.entries(o).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function Nu(o,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>o.apply(this,i),t)}}var Vu=Object.defineProperty,Wu=Object.getOwnPropertyDescriptor,Dt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Wu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Vu(t,e,s),s};let K=class extends gt{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.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=K.CTA_STATES.primary,this.wrappedSubmitTypeForm=async t=>{console.warn("submitTypingForm function not implemented",t)},this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}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")})}get formData(){var e,i,s,r,n,a,l,c;const t={pboCardId:((e=this.card)==null?void 0:e.pboId)||"Unknown",productId:(i=this.card)==null?void 0:i.productId,sku:(s=this.card)==null?void 0:s.sku,variantId:(r=this.card)==null?void 0:r.variantId,font:((n=this.fontSelector)==null?void 0:n.value)||"",text:((a=this.greetingText)==null?void 0:a.value)||"",color:((l=this.textColor)==null?void 0:l.value)||"",alignment:((c=this.textAlignment)==null?void 0:c.value)||""};return Kl(t)}handleFormChange(t){var e;this.ctaButtonState=K.CTA_STATES.primary,this.charsNum=((e=this.greetingText)==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.greetingText.value===""||this.greetingText.value===null||this.greetingText.value===void 0){this.ctaButtonState=K.CTA_STATES.danger,this.greetingText.focus();return}this.wrappedSubmitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=223-this.charsNum;return L`
1478
+ `,pi=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),ws=o=>o!=null,Kl=o=>Object.entries(o).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function Nu(o,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>o.apply(this,i),t)}}var Vu=Object.defineProperty,Wu=Object.getOwnPropertyDescriptor,Dt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Wu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Vu(t,e,s),s};let K=class extends gt{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.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=K.CTA_STATES.primary,this.wrappedSubmitTypeForm=async t=>{console.warn("submitTypingForm function not implemented",t)},this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}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")})}get formData(){var e,i,s,r,n,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:(n=this.card)==null?void 0:n.variantId,font:((a=this.fontSelector)==null?void 0:a.value)||"",text:((l=this.greetingText)==null?void 0:l.value)||"",color:((c=this.textColor)==null?void 0:c.value)||"",alignment:((h=this.textAlignment)==null?void 0:h.value)||""};return Kl(t)}handleFormChange(t){var e;this.ctaButtonState=K.CTA_STATES.primary,this.charsNum=((e=this.greetingText)==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.greetingText.value===""||this.greetingText.value===null||this.greetingText.value===void 0){this.ctaButtonState=K.CTA_STATES.danger,this.greetingText.focus();return}this.wrappedSubmitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=223-this.charsNum;return L`
1479
1479
  <form class="typing-form" @submit=${this.submitFormHandler}>
1480
1480
  <pbo-textarea
1481
1481
  exportparts="textarea:editor-textarea"
@@ -2906,7 +2906,7 @@
2906
2906
  style="${pe({"--track-width":"3px","--indicator-color":"black"})}"
2907
2907
  ></pbo-spinner>
2908
2908
  <span>${Math.round(this.progress)}%</span>
2909
- </div>`}};ze.styles=[pt,Qp];ze.dependencies={"pbo-spinner":rs};Xs([C({type:Boolean,reflect:!0})],ze.prototype,"loading",2);Xs([C({type:Number})],ze.prototype,"loadingTime",2);Xs([C()],ze.prototype,"loadingPattern",2);Xs([R()],ze.prototype,"progress",2);ze=Xs([ht("pbo-fake-loading")],ze);var ig=Object.defineProperty,sg=Object.getOwnPropertyDescriptor,st=(o,t,e,i)=>{for(var s=i>1?void 0:i?sg(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&ig(t,e,s),s};let Z=class extends gt{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{masked_img:"",uid:""}),this.onClose=()=>{console.warn("onClose not implemented")},this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isProcessingError=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsError(t){this.uploadButton&&this.saveButton&&(this.uploadButton.variant=t?"danger":"primary",this.saveButton.variant=t?"danger":"primary",this.uploadButton.value=t?"Error uploading image":"Upload Handwritten Image")}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleProcessingErrorChange(){this.setButtonsError(this.isProcessingError)}handleSourceImgChange(t,e){this.processedImg={uid:null,masked_img:null},this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing),this.emit("pbo-image-processing",{detail:{isLoading:this.isImageProcessing}})}get formData(){var s,r,n,a;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={pboCardId:((s=this.card)==null?void 0:s.pboId)||"Unknown",productId:(r=this.card)==null?void 0:r.productId,sku:(n=this.card)==null?void 0:n.sku,variantId:(a=this.card)==null?void 0:a.variantId,pred_image_uid:this.processedImg.uid||"",position_x:this.handwrittenDimensions.top*e,position_y:this.handwrittenDimensions.left*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return Kl(i)}setDimensions(t){this.handwrittenDimensions=t}handleProcessedImgChange(){this.processedImg.masked_img&&this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:this.processedImg.masked_img}})}async handleFileChange(t){var i,s;this.sourceImg===null&&this.processedImg.masked_img===null?this.emit("pbo_edit_handwritten_form",{detail:{action:"upload"}}):this.emit("pbo_edit_handwritten_form",{detail:{action:"reupload"}}),this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.isProcessingError=!1;const e=(s=(i=t.target)==null?void 0:i.files)==null?void 0:s[0];if(e!=null){this.sourceImg=e,this.isImageProcessing=!0,this.updateComplete.then(()=>{this.uploadButton.scrollIntoView(!0)});try{const r=await this.getProcessedImg(e);this.processedImg={masked_img:`data:image/png;base64,${r.masked_img}`,uid:r.uid}}catch{this.isProcessingError=!0}finally{this.isImageProcessing=!1}}}async handleSubmit(t){t.preventDefault(),this.isSubmitLoading=!0,this.isSubmitDisabled=!0;try{await this.submitHandwrittenForm(this.formData),this.onClose(),this.emit("pbo-handwritten-form-submitted")}catch(e){console.error("Error submitting handwritten form:",e)}finally{this.isSubmitLoading=!1,this.isSubmitDisabled=!1}}render(){return L`
2909
+ </div>`}};ze.styles=[pt,Qp];ze.dependencies={"pbo-spinner":rs};Xs([C({type:Boolean,reflect:!0})],ze.prototype,"loading",2);Xs([C({type:Number})],ze.prototype,"loadingTime",2);Xs([C()],ze.prototype,"loadingPattern",2);Xs([R()],ze.prototype,"progress",2);ze=Xs([ht("pbo-fake-loading")],ze);var ig=Object.defineProperty,sg=Object.getOwnPropertyDescriptor,st=(o,t,e,i)=>{for(var s=i>1?void 0:i?sg(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&ig(t,e,s),s};let Z=class extends gt{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{masked_img:"",uid:""}),this.onClose=()=>{console.warn("onClose not implemented")},this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isProcessingError=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsError(t){this.uploadButton&&this.saveButton&&(this.uploadButton.variant=t?"danger":"primary",this.saveButton.variant=t?"danger":"primary",this.uploadButton.value=t?"Error uploading image":"Upload Handwritten Image")}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleProcessingErrorChange(){this.setButtonsError(this.isProcessingError)}handleSourceImgChange(t,e){this.processedImg={uid:null,masked_img:null},this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing),this.emit("pbo-image-processing",{detail:{isLoading:this.isImageProcessing}})}get formData(){var s,r,n,a,l;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={barcode:((s=this.card)==null?void 0:s.barcode)||"",pboCardId:((r=this.card)==null?void 0:r.pboId)||"Unknown",productId:(n=this.card)==null?void 0:n.productId,sku:(a=this.card)==null?void 0:a.sku,variantId:(l=this.card)==null?void 0:l.variantId,pred_image_uid:this.processedImg.uid||"",position_x:this.handwrittenDimensions.top*e,position_y:this.handwrittenDimensions.left*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return Kl(i)}setDimensions(t){this.handwrittenDimensions=t}handleProcessedImgChange(){this.processedImg.masked_img&&this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:this.processedImg.masked_img}})}async handleFileChange(t){var i,s;this.sourceImg===null&&this.processedImg.masked_img===null?this.emit("pbo_edit_handwritten_form",{detail:{action:"upload"}}):this.emit("pbo_edit_handwritten_form",{detail:{action:"reupload"}}),this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.isProcessingError=!1;const e=(s=(i=t.target)==null?void 0:i.files)==null?void 0:s[0];if(e!=null){this.sourceImg=e,this.isImageProcessing=!0,this.updateComplete.then(()=>{this.uploadButton.scrollIntoView(!0)});try{const r=await this.getProcessedImg(e);this.processedImg={masked_img:`data:image/png;base64,${r.masked_img}`,uid:r.uid}}catch{this.isProcessingError=!0}finally{this.isImageProcessing=!1}}}async handleSubmit(t){t.preventDefault(),this.isSubmitLoading=!0,this.isSubmitDisabled=!0;try{await this.submitHandwrittenForm(this.formData),this.onClose(),this.emit("pbo-handwritten-form-submitted")}catch(e){console.error("Error submitting handwritten form:",e)}finally{this.isSubmitLoading=!1,this.isSubmitDisabled=!1}}render(){return L`
2910
2910
  <form name="handwritten-form" class="handwritten-form" @submit=${this.handleSubmit}>
2911
2911
  <div class="handwritten-tutorials">
2912
2912
  <section>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pairbo/ui-kit",
3
- "version": "0.3.28",
3
+ "version": "0.3.29",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "readme": "./README-NPM.md",