@pairbo/ui-kit 0.1.1 → 0.2.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/pairbo.es.js CHANGED
@@ -15246,6 +15246,15 @@ const styles$b = i$7`
15246
15246
  font-size: var(--pbo-font-size-medium);
15247
15247
  }
15248
15248
  `;
15249
+ const isMobileDevice = () => {
15250
+ return /Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
15251
+ };
15252
+ const isValid = (value) => {
15253
+ return value !== null && value !== void 0;
15254
+ };
15255
+ const removeNullUndefined = (obj) => Object.entries(obj).reduce((acc, [k3, v2]) => {
15256
+ return v2 == null ? acc : (acc[k3] = v2, acc);
15257
+ }, {});
15249
15258
  var __defProp$c = Object.defineProperty;
15250
15259
  var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
15251
15260
  var __decorateClass$c = (decorators, target, key, kind) => {
@@ -15261,15 +15270,13 @@ let PboTypeForm$1 = class PboTypeForm extends PairboElement {
15261
15270
  super(...arguments);
15262
15271
  this.windowHeight = window.innerHeight;
15263
15272
  this.resizeTimeout = null;
15264
- this.formData = {
15265
- font: "",
15266
- text: "",
15267
- color: "",
15268
- alignment: ""
15269
- };
15270
15273
  this.charsNum = 0;
15271
15274
  this.ctaButtonState = PboTypeForm$1.CTA_STATES.primary;
15272
15275
  this.cardInnerImageUrl = "../../../public/Greeting Card from Pairbo.png";
15276
+ this.card = null;
15277
+ this.submitTypeForm = (formData) => {
15278
+ console.error("submitTypingForm function not implemented", formData);
15279
+ };
15273
15280
  this.handleResize = () => {
15274
15281
  if (this.resizeTimeout) {
15275
15282
  window.clearTimeout(this.resizeTimeout);
@@ -15284,34 +15291,24 @@ let PboTypeForm$1 = class PboTypeForm extends PairboElement {
15284
15291
  alert("Please add a message to continue");
15285
15292
  });
15286
15293
  }
15287
- get form() {
15288
- var _a2, _b, _c, _d;
15289
- return {
15290
- font: (_a2 = this.fontSelector) == null ? void 0 : _a2.value,
15291
- text: (_b = this.greetingText) == null ? void 0 : _b.value,
15292
- color: (_c = this.textColor) == null ? void 0 : _c.value,
15293
- alignment: (_d = this.textAlignment) == null ? void 0 : _d.value
15294
+ get formData() {
15295
+ var _a2, _b, _c, _d, _e2, _f, _g, _h;
15296
+ const formData = {
15297
+ pboCardId: ((_a2 = this.card) == null ? void 0 : _a2.pboId) || "Unknown",
15298
+ productId: (_b = this.card) == null ? void 0 : _b.productId,
15299
+ sku: (_c = this.card) == null ? void 0 : _c.sku,
15300
+ variantId: (_d = this.card) == null ? void 0 : _d.variantId,
15301
+ font: ((_e2 = this.fontSelector) == null ? void 0 : _e2.value) || "",
15302
+ text: ((_f = this.greetingText) == null ? void 0 : _f.value) || "",
15303
+ color: ((_g = this.textColor) == null ? void 0 : _g.value) || "",
15304
+ alignment: ((_h = this.textAlignment) == null ? void 0 : _h.value) || ""
15294
15305
  };
15306
+ return removeNullUndefined(formData);
15295
15307
  }
15296
15308
  handleFormChange(e3) {
15297
- var _a2;
15298
15309
  this.ctaButtonState = PboTypeForm$1.CTA_STATES.primary;
15299
- const target = e3.target;
15300
- const tempForm = {
15301
- ...this.formData
15302
- };
15303
- if (target.classList.contains("font-selector")) {
15304
- tempForm.font = ((_a2 = target == null ? void 0 : target.value) == null ? void 0 : _a2.value) || " Font form control not implemented yet";
15305
- } else if (target.classList.contains("greeting-text")) {
15306
- tempForm.text = target.value;
15307
- } else if (target.classList.contains("text-color")) {
15308
- tempForm.color = target.value;
15309
- } else if (target.classList.contains("text-alignment")) {
15310
- tempForm.alignment = target.value;
15311
- }
15312
- this.formData = { ...tempForm };
15313
15310
  this.emit("pbo-change", {
15314
- detail: this.form
15311
+ detail: this.formData
15315
15312
  });
15316
15313
  }
15317
15314
  hostConnected() {
@@ -15326,7 +15323,7 @@ let PboTypeForm$1 = class PboTypeForm extends PairboElement {
15326
15323
  const submitterName = (_a2 = e3.submitter) == null ? void 0 : _a2.name;
15327
15324
  if (this.ctaButtonState.type === "danger") {
15328
15325
  if (submitterName === "skip") {
15329
- alert("Skipping, adding empty message");
15326
+ this.submitTypeForm(this.formData);
15330
15327
  }
15331
15328
  return;
15332
15329
  }
@@ -15335,7 +15332,7 @@ let PboTypeForm$1 = class PboTypeForm extends PairboElement {
15335
15332
  this.greetingText.focus();
15336
15333
  return;
15337
15334
  }
15338
- alert("Form submitted with data:");
15335
+ this.submitTypeForm(this.formData);
15339
15336
  }
15340
15337
  connectedCallback() {
15341
15338
  super.connectedCallback();
@@ -15494,9 +15491,6 @@ __decorateClass$c([
15494
15491
  __decorateClass$c([
15495
15492
  r$3()
15496
15493
  ], PboTypeForm$1.prototype, "windowHeight", 2);
15497
- __decorateClass$c([
15498
- r$3()
15499
- ], PboTypeForm$1.prototype, "formData", 2);
15500
15494
  __decorateClass$c([
15501
15495
  r$3()
15502
15496
  ], PboTypeForm$1.prototype, "charsNum", 2);
@@ -15506,6 +15500,12 @@ __decorateClass$c([
15506
15500
  __decorateClass$c([
15507
15501
  n$3({ type: String, reflect: true })
15508
15502
  ], PboTypeForm$1.prototype, "cardInnerImageUrl", 2);
15503
+ __decorateClass$c([
15504
+ n$3()
15505
+ ], PboTypeForm$1.prototype, "card", 2);
15506
+ __decorateClass$c([
15507
+ n$3()
15508
+ ], PboTypeForm$1.prototype, "submitTypeForm", 2);
15509
15509
  PboTypeForm$1 = __decorateClass$c([
15510
15510
  t$3("pbo-type-form")
15511
15511
  ], PboTypeForm$1);
@@ -15655,12 +15655,6 @@ const styles$a = i$7`
15655
15655
  }
15656
15656
  `;
15657
15657
  const splideCss = ".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}";
15658
- const isMobileDevice = () => {
15659
- return /Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
15660
- };
15661
- const isValid = (value) => {
15662
- return value !== null && value !== void 0;
15663
- };
15664
15658
  var __defProp$b = Object.defineProperty;
15665
15659
  var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
15666
15660
  var __decorateClass$b = (decorators, target, key, kind) => {
@@ -16007,7 +16001,7 @@ let PboEditor$1 = class PboEditor extends PairboElement {
16007
16001
  this.handwrittenFormState = { isLoading: false, processedFileUrl: "" };
16008
16002
  this.editorType = "type";
16009
16003
  this.handleTypingFormChange = () => {
16010
- this.formData = this.typingForm.form;
16004
+ this.formData = this.typeForm.formData;
16011
16005
  this.slider.focusOn(1);
16012
16006
  };
16013
16007
  this.handelHandwrittenFormChange = (e3) => {
@@ -16032,7 +16026,7 @@ let PboEditor$1 = class PboEditor extends PairboElement {
16032
16026
  this.addEventListener("handwritten-image-dimensions-changed", (e3) => {
16033
16027
  this.handwrittenForm.setDimensions(e3.detail);
16034
16028
  });
16035
- this.typingForm.addEventListener("pbo-change", this.handleTypingFormChange);
16029
+ this.typeForm.addEventListener("pbo-change", this.handleTypingFormChange);
16036
16030
  this.handwrittenForm.addEventListener("pbo-change", this.handelHandwrittenFormChange);
16037
16031
  document.addEventListener("pbo-zoomed-preview-open", () => {
16038
16032
  this.openZoomedPreview();
@@ -16045,19 +16039,12 @@ let PboEditor$1 = class PboEditor extends PairboElement {
16045
16039
  if (this.card) {
16046
16040
  this.slider.card = this.card;
16047
16041
  this.requestUpdate();
16042
+ this.typeForm.card = this.card;
16043
+ this.handwrittenForm.card = this.card;
16048
16044
  }
16049
16045
  }
16050
- // updated(changedProperties: PropertyValues<this>): void {
16051
- // if (changedProperties.has("cardInnerImageUrl")) {
16052
- // this.requestUpdate();
16053
- // }
16054
- // if (changedProperties.has("card")) {
16055
- // this.slider.card = this.card;
16056
- // this.requestUpdate();
16057
- // }
16058
- // }
16059
16046
  disconnectedCallback() {
16060
- this.typingForm.removeEventListener("pbo-change", this.handleTypingFormChange);
16047
+ this.typeForm.removeEventListener("pbo-change", this.handleTypingFormChange);
16061
16048
  this.handwrittenForm.removeEventListener("pbo-change", this.handelHandwrittenFormChange);
16062
16049
  }
16063
16050
  render() {
@@ -16076,6 +16063,7 @@ let PboEditor$1 = class PboEditor extends PairboElement {
16076
16063
  <div class="editor__form">
16077
16064
  <pbo-editor-selector @pbo-change=${this.handleEditorChange}></pbo-editor-selector>
16078
16065
  <pbo-type-form
16066
+ .submitTypeForm=${this.submitTypeForm}
16079
16067
  style=${o$1({
16080
16068
  display: this.editorType === "type" ? "block" : "none"
16081
16069
  })}
@@ -16084,6 +16072,8 @@ let PboEditor$1 = class PboEditor extends PairboElement {
16084
16072
  style=${o$1({
16085
16073
  display: this.editorType === "handwritten" ? "block" : "none"
16086
16074
  })}
16075
+ .submitHandwrittenForm=${this.submitHandwrittenForm}
16076
+ .getProcessedImg=${this.getProcessedImg}
16087
16077
  ></pbo-handwritten-form>
16088
16078
  </div>
16089
16079
  </div>
@@ -16116,9 +16106,21 @@ PboEditor$1.dependencies = {
16116
16106
  __decorateClass$a([
16117
16107
  n$3({ type: String, reflect: true })
16118
16108
  ], PboEditor$1.prototype, "cardInnerImageUrl", 2);
16109
+ __decorateClass$a([
16110
+ n$3({ type: Object })
16111
+ ], PboEditor$1.prototype, "card", 2);
16112
+ __decorateClass$a([
16113
+ n$3()
16114
+ ], PboEditor$1.prototype, "submitTypeForm", 2);
16115
+ __decorateClass$a([
16116
+ n$3()
16117
+ ], PboEditor$1.prototype, "submitHandwrittenForm", 2);
16118
+ __decorateClass$a([
16119
+ n$3()
16120
+ ], PboEditor$1.prototype, "getProcessedImg", 2);
16119
16121
  __decorateClass$a([
16120
16122
  e$5("pbo-type-form")
16121
- ], PboEditor$1.prototype, "typingForm", 2);
16123
+ ], PboEditor$1.prototype, "typeForm", 2);
16122
16124
  __decorateClass$a([
16123
16125
  e$5("pbo-handwritten-form")
16124
16126
  ], PboEditor$1.prototype, "handwrittenForm", 2);
@@ -16128,9 +16130,6 @@ __decorateClass$a([
16128
16130
  __decorateClass$a([
16129
16131
  e$5(".editor__zoomed")
16130
16132
  ], PboEditor$1.prototype, "zoomedPreview", 2);
16131
- __decorateClass$a([
16132
- n$3({ type: Object })
16133
- ], PboEditor$1.prototype, "card", 2);
16134
16133
  __decorateClass$a([
16135
16134
  r$3()
16136
16135
  ], PboEditor$1.prototype, "formData", 2);
@@ -18869,7 +18868,7 @@ let PboCategory$1 = class PboCategory extends PairboElement {
18869
18868
  src=${card.medias.cover.url}
18870
18869
  alt="${card.medias.cover.alt}"
18871
18870
  @click=${this.clickHandler}
18872
- data-card-id="${card.id}"
18871
+ data-card-id="${card.pboId}"
18873
18872
  />
18874
18873
  </li>
18875
18874
  `;
@@ -19211,8 +19210,8 @@ let PboPageManager$1 = class PboPageManager extends PairboElement {
19211
19210
  this.onClose = () => {
19212
19211
  };
19213
19212
  this.currentPage = "selection";
19214
- this.selectedCard = null;
19215
19213
  this.categories = [];
19214
+ this.selectedCard = null;
19216
19215
  this.selectedCardId = null;
19217
19216
  this.selectedCardDetails = null;
19218
19217
  this.handleCardSelected = (event) => {
@@ -19223,6 +19222,15 @@ let PboPageManager$1 = class PboPageManager extends PairboElement {
19223
19222
  this.goToEditor();
19224
19223
  };
19225
19224
  }
19225
+ handleSubmitTypeFormUpdate() {
19226
+ this.editorEl.submitTypeForm = this.submitTypeForm;
19227
+ }
19228
+ handleSubmitHandwrittenFormUpdate() {
19229
+ this.editorEl.submitHandwrittenForm = this.submitHandwrittenForm;
19230
+ }
19231
+ handleGetProcessedImgUpdate() {
19232
+ this.editorEl.getProcessedImg = this.getProcessedImg;
19233
+ }
19226
19234
  goToEditor() {
19227
19235
  this.currentPage = "editor";
19228
19236
  }
@@ -19252,7 +19260,7 @@ let PboPageManager$1 = class PboPageManager extends PairboElement {
19252
19260
  findCardInCategoryById(cardId) {
19253
19261
  console.log("Categories from findCardInCategoryById", this.categories);
19254
19262
  for (const category of this.categories) {
19255
- const card = category.cards.find((card2) => card2.id === cardId);
19263
+ const card = category.cards.find((card2) => card2.pboId === cardId);
19256
19264
  console.log("card from findCardInCategoryById", card);
19257
19265
  if (card) {
19258
19266
  return card;
@@ -19319,18 +19327,36 @@ __decorateClass$7([
19319
19327
  __decorateClass$7([
19320
19328
  n$3({ type: String, reflect: true })
19321
19329
  ], PboPageManager$1.prototype, "currentPage", 2);
19322
- __decorateClass$7([
19323
- r$3()
19324
- ], PboPageManager$1.prototype, "selectedCard", 2);
19325
19330
  __decorateClass$7([
19326
19331
  n$3()
19327
19332
  ], PboPageManager$1.prototype, "categories", 2);
19333
+ __decorateClass$7([
19334
+ n$3()
19335
+ ], PboPageManager$1.prototype, "submitTypeForm", 2);
19336
+ __decorateClass$7([
19337
+ n$3()
19338
+ ], PboPageManager$1.prototype, "submitHandwrittenForm", 2);
19339
+ __decorateClass$7([
19340
+ n$3()
19341
+ ], PboPageManager$1.prototype, "getProcessedImg", 2);
19342
+ __decorateClass$7([
19343
+ r$3()
19344
+ ], PboPageManager$1.prototype, "selectedCard", 2);
19328
19345
  __decorateClass$7([
19329
19346
  r$3()
19330
19347
  ], PboPageManager$1.prototype, "selectedCardId", 2);
19331
19348
  __decorateClass$7([
19332
19349
  r$3()
19333
19350
  ], PboPageManager$1.prototype, "selectedCardDetails", 2);
19351
+ __decorateClass$7([
19352
+ watch("submitTypeForm")
19353
+ ], PboPageManager$1.prototype, "handleSubmitTypeFormUpdate", 1);
19354
+ __decorateClass$7([
19355
+ watch("submitHandwrittenForm")
19356
+ ], PboPageManager$1.prototype, "handleSubmitHandwrittenFormUpdate", 1);
19357
+ __decorateClass$7([
19358
+ watch("getProcessedImg")
19359
+ ], PboPageManager$1.prototype, "handleGetProcessedImgUpdate", 1);
19334
19360
  __decorateClass$7([
19335
19361
  watch("categories")
19336
19362
  ], PboPageManager$1.prototype, "handleCategoriesUpdate", 1);
@@ -19961,7 +19987,22 @@ var __decorateClass$2 = (decorators, target, key, kind) => {
19961
19987
  let PboHandwrittenForm$1 = class PboHandwrittenForm extends PairboElement {
19962
19988
  constructor() {
19963
19989
  super(...arguments);
19990
+ this.card = null;
19991
+ this.submitHandwrittenForm = (formData) => {
19992
+ console.warn("submitHandwrittenForm not implemented", formData);
19993
+ };
19994
+ this.getProcessedImg = async (file) => {
19995
+ console.warn("getProcessedImg not implemented", file.name);
19996
+ return {
19997
+ pred_image_uid: "",
19998
+ masked_img: ""
19999
+ };
20000
+ };
19964
20001
  this.sourceImg = null;
20002
+ this.processedImg = {
20003
+ fileUrl: null,
20004
+ imgId: null
20005
+ };
19965
20006
  this.processedFileUrl = null;
19966
20007
  this.handwrittenDimensions = {
19967
20008
  top: null,
@@ -19997,6 +20038,23 @@ let PboHandwrittenForm$1 = class PboHandwrittenForm extends PairboElement {
19997
20038
  }
19998
20039
  });
19999
20040
  }
20041
+ get formData() {
20042
+ var _a2, _b, _c, _d;
20043
+ const pixelsPerMMHeight = 177.8 / this.handwrittenDimensions.cardHeight;
20044
+ const pixelsPerMMWidth = 127 / this.handwrittenDimensions.cardWidth;
20045
+ const formData = {
20046
+ pboCardId: ((_a2 = this.card) == null ? void 0 : _a2.pboId) || "Unknown",
20047
+ productId: (_b = this.card) == null ? void 0 : _b.productId,
20048
+ sku: (_c = this.card) == null ? void 0 : _c.sku,
20049
+ variantId: (_d = this.card) == null ? void 0 : _d.variantId,
20050
+ pred_image_uid: this.processedImg.imgId || "",
20051
+ position_x: this.handwrittenDimensions.top * pixelsPerMMWidth,
20052
+ position_y: this.handwrittenDimensions.left * pixelsPerMMHeight,
20053
+ height: this.handwrittenDimensions.height * pixelsPerMMHeight,
20054
+ width: this.handwrittenDimensions.width * pixelsPerMMWidth
20055
+ };
20056
+ return removeNullUndefined(formData);
20057
+ }
20000
20058
  setDimensions(dimensions) {
20001
20059
  this.handwrittenDimensions = dimensions;
20002
20060
  }
@@ -20011,36 +20069,12 @@ let PboHandwrittenForm$1 = class PboHandwrittenForm extends PairboElement {
20011
20069
  const file = (_b = (_a2 = e3.target) == null ? void 0 : _a2.files) == null ? void 0 : _b[0];
20012
20070
  if (file == null) return;
20013
20071
  this.sourceImg = file;
20014
- const fetchSimulation = () => new Promise((resolve) => {
20015
- setTimeout(() => {
20016
- resolve({ fileUrl: file ? URL.createObjectURL(file) : null });
20017
- }, 2e3);
20018
- });
20019
- const processedFileUrl = await fetchSimulation();
20020
- this.processedFileUrl = processedFileUrl.fileUrl;
20072
+ const processedImage = await this.getProcessedImg(file);
20073
+ this.processedFileUrl = `data:image/png;base64,${processedImage.masked_img}`;
20021
20074
  }
20022
20075
  handleSubmit(e3) {
20023
20076
  e3.preventDefault();
20024
- console.log(e3);
20025
- const pixelsPerMMHeight = 177.8 / this.handwrittenDimensions.cardHeight;
20026
- const pixelsPerMMWidth = 127 / this.handwrittenDimensions.cardWidth;
20027
- let formData = {
20028
- items: [
20029
- {
20030
- // id: card.shopifyVariantId,
20031
- quantity: 1,
20032
- properties: {
20033
- // _pairbo_id: card.pairboId,
20034
- // _pred_image_uid: imgId,
20035
- _position_x: this.handwrittenDimensions.top * pixelsPerMMWidth,
20036
- _position_y: this.handwrittenDimensions.left * pixelsPerMMHeight,
20037
- _height: this.handwrittenDimensions.height * pixelsPerMMHeight,
20038
- _width: this.handwrittenDimensions.width * pixelsPerMMWidth
20039
- }
20040
- }
20041
- ]
20042
- };
20043
- console.log(formData);
20077
+ this.submitHandwrittenForm(this.formData);
20044
20078
  }
20045
20079
  render() {
20046
20080
  return x$1`
@@ -20090,8 +20124,9 @@ let PboHandwrittenForm$1 = class PboHandwrittenForm extends PairboElement {
20090
20124
  style=${o$1({
20091
20125
  display: this.sourceImg && this.processedFileUrl ? "block" : "none"
20092
20126
  })}
20093
- >Save and Continue</pbo-button
20094
20127
  >
20128
+ Save and Continue
20129
+ </pbo-button>
20095
20130
  <pbo-button
20096
20131
  name="reupload"
20097
20132
  variant="text"
@@ -20116,9 +20151,21 @@ __decorateClass$2([
20116
20151
  __decorateClass$2([
20117
20152
  e$5(".handwritten-form")
20118
20153
  ], PboHandwrittenForm$1.prototype, "handwrittenForm", 2);
20154
+ __decorateClass$2([
20155
+ n$3()
20156
+ ], PboHandwrittenForm$1.prototype, "card", 2);
20157
+ __decorateClass$2([
20158
+ n$3()
20159
+ ], PboHandwrittenForm$1.prototype, "submitHandwrittenForm", 2);
20160
+ __decorateClass$2([
20161
+ n$3()
20162
+ ], PboHandwrittenForm$1.prototype, "getProcessedImg", 2);
20119
20163
  __decorateClass$2([
20120
20164
  r$3()
20121
20165
  ], PboHandwrittenForm$1.prototype, "sourceImg", 2);
20166
+ __decorateClass$2([
20167
+ r$3()
20168
+ ], PboHandwrittenForm$1.prototype, "processedImg", 2);
20122
20169
  __decorateClass$2([
20123
20170
  r$3()
20124
20171
  ], PboHandwrittenForm$1.prototype, "processedFileUrl", 2);
@@ -20219,6 +20266,7 @@ let PboHandwrittenCanvas$1 = class PboHandwrittenCanvas extends PairboElement {
20219
20266
  this.handwrittenImage.selectable = true;
20220
20267
  this.handwrittenImage.lockRotation = true;
20221
20268
  this.handwrittenImage.lockScalingFlip = true;
20269
+ this.handwrittenImage.noScaleCache = false;
20222
20270
  const scaleWidth = this.areaSize.width / this.handwrittenImage.width;
20223
20271
  const scaleHeight = this.areaSize.height / this.handwrittenImage.height;
20224
20272
  const scale = Math.min(scaleWidth, scaleHeight);
@@ -20237,7 +20285,7 @@ let PboHandwrittenCanvas$1 = class PboHandwrittenCanvas extends PairboElement {
20237
20285
  scaleY: scale,
20238
20286
  bringToFrontOnSelect: false,
20239
20287
  borderColor: "#4287f5",
20240
- borderScaleFactor: 1.5
20288
+ borderScaleFactor: 10
20241
20289
  });
20242
20290
  this.setHandwrittenImageDimensions({
20243
20291
  top: this.areaPosition.top,