@foxy.io/elements 1.60.1 → 1.60.3
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/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/shared-8062bbb8.js +1 -0
- package/dist/cdn/translations/admin-subscription-form/en.json +0 -1
- package/dist/cdn/translations/customer/en.json +1 -1
- package/dist/cdn/translations/customer-form/en.json +3 -2
- package/dist/cdn/translations/customer-portal/en.json +3 -2
- package/dist/cdn/translations/payment-card/en.json +0 -1
- package/dist/cdn/translations/transaction/en.json +0 -1
- package/dist/elements/public/CustomerForm/CustomerForm.d.ts +2 -0
- package/dist/elements/public/CustomerForm/CustomerForm.js +16 -3
- package/dist/elements/public/CustomerForm/CustomerForm.js.map +1 -1
- package/dist/elements/public/PaymentCard/PaymentCard.js +16 -5
- package/dist/elements/public/PaymentCard/PaymentCard.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-ad5617ef.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-a6b2bd14.js";import"./shared-af4f71bf.js";import"./shared-32a39c0b.js";import"./shared-091e97f3.js";import"./shared-9b290320.js";export{C as CustomerForm}from"./shared-
|
|
1
|
+
import"./shared-a6b2bd14.js";import"./shared-af4f71bf.js";import"./shared-32a39c0b.js";import"./shared-091e97f3.js";import"./shared-9b290320.js";export{C as CustomerForm}from"./shared-8062bbb8.js";import"./shared-dc6e5879.js";import"./shared-f410644a.js";import"./shared-5b8c7250.js";import"./shared-8f9014ff.js";import"./shared-ba5c42c7.js";import"./shared-f77994ad.js";import"./shared-a8ae24f0.js";import"./shared-c56c3e1e.js";import"./shared-c3d6bcc0.js";import"./shared-4ab85bea.js";import"./shared-5212ef4f.js";import"./shared-c066b7fd.js";import"./shared-930e68b7.js";import"./shared-222b23bb.js";import"./shared-53e42a77.js";import"./shared-87e17c02.js";import"./shared-c85c1864.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-4e709717.js";import"./shared-5dbd66e3.js";import"./shared-28cc8aa1.js";import"./shared-53a5212e.js";import"./shared-e9f51baa.js";import"./foxy-copy-to-clipboard.js";import"./shared-affe06c0.js";import"./shared-c59277a4.js";import"./shared-cfc6735e.js";import"./shared-cf1965cb.js";import"./shared-d0aed1c1.js";import"./shared-cda51ccf.js";import"./shared-41f93e6c.js";import"./foxy-spinner.js";import"./shared-bab2ea2c.js";import"./shared-b738ee96.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./foxy-customer.js";import"./shared-a8ae24f0.js";import"./shared-cf1965cb.js";import"./shared-c59277a4.js";import"./shared-32a39c0b.js";import"./shared-5212ef4f.js";import{I as e}from"./shared-9b290320.js";import"./foxy-access-recovery-form.js";import"./foxy-payment-method-card.js";import{TransactionsTable as t}from"./foxy-transactions-table.js";import"./foxy-subscription-card.js";import"./foxy-subscription-form.js";import"./foxy-collection-pages.js";import"./foxy-collection-page.js";import{u as s}from"./shared-
|
|
1
|
+
import"./foxy-customer.js";import"./shared-a8ae24f0.js";import"./shared-cf1965cb.js";import"./shared-c59277a4.js";import"./shared-32a39c0b.js";import"./shared-5212ef4f.js";import{I as e}from"./shared-9b290320.js";import"./foxy-access-recovery-form.js";import"./foxy-payment-method-card.js";import{TransactionsTable as t}from"./foxy-transactions-table.js";import"./foxy-subscription-card.js";import"./foxy-subscription-form.js";import"./foxy-collection-pages.js";import"./foxy-collection-page.js";import{u as s}from"./shared-8062bbb8.js";import"./foxy-sign-in-form.js";import"./foxy-form-dialog.js";import"./foxy-spinner.js";import"./shared-c066b7fd.js";import{_ as r,B as o,aI as i}from"./shared-8f9014ff.js";import{h as a,L as n,c as d}from"./shared-ba5c42c7.js";import{A as l}from"./shared-7f7d6ceb.js";import"./shared-11de7969.js";import{C as c}from"./shared-0b0ab3d2.js";import{a as m,T as u}from"./shared-5b8c7250.js";import{U as p}from"./shared-cd96ff03.js";import{i as h}from"./shared-53e42a77.js";import{c as f}from"./shared-4e709717.js";import{A as g}from"./shared-69c98b7b.js";import{C as y}from"./shared-222b23bb.js";import{I as $}from"./shared-930e68b7.js";import"./shared-f410644a.js";import"./foxy-update-payment-method-form.js";import"./shared-eb349085.js";import"./shared-3a61d8a6.js";import"./shared-dc6e5879.js";import"./shared-c3d6bcc0.js";import"./shared-f77994ad.js";import"./shared-91483320.js";import"./shared-d8b880bb.js";import"./shared-6262e0d6.js";import"./shared-28cc8aa1.js";import"./shared-2fbfbe12.js";import"./shared-e9f51baa.js";import"./shared-53a5212e.js";import"./shared-c56c3e1e.js";import"./shared-8be109a9.js";import"./shared-4ab85bea.js";import"./shared-c85c1864.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-87e17c02.js";import"./shared-0e19bda5.js";import"./foxy-swipe-actions.js";import"./foxy-pagination.js";import"./shared-7e28c953.js";import"./shared-56741bad.js";import"./shared-a95a66b8.js";import"./shared-cda51ccf.js";import"./shared-41f93e6c.js";import"./foxy-copy-to-clipboard.js";import"./shared-affe06c0.js";import"./shared-cfc6735e.js";import"./foxy-nucleon-element.js";import"./shared-53e476fd.js";import"./shared-bab2ea2c.js";import"./foxy-template-set-card.js";import"./shared-18707481.js";import"./shared-56278a3c.js";import"./foxy-payment-card-embed.js";import"./shared-142df717.js";import"./shared-5fd5805c.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./shared-af4f71bf.js";import"./shared-4ed4b075.js";import"./foxy-address-card.js";import"./foxy-address-form.js";import"./shared-e9f9face.js";import"./shared-091e97f3.js";import"./shared-d0aed1c1.js";import"./foxy-table.js";import"./shared-3ef23488.js";import"./shared-0811ea40.js";import"./shared-34262bb8.js";import"./shared-62ee726e.js";import"./shared-a08f594b.js";import"./shared-48910b3f.js";import"./shared-b48cd5d3.js";import"./shared-8f5c8c08.js";import"./shared-1b414966.js";import"./shared-96e4f603.js";import"./shared-cf613436.js";import"./shared-e2a5457f.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";import"./shared-2061be9a.js";import"./foxy-transaction-card.js";import"./shared-0996f4d0.js";import"./shared-345b07f1.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./shared-c84333db.js";import"./shared-2fbff8e7.js";import"./shared-a6b2bd14.js";import"./shared-5dbd66e3.js";import"./shared-b738ee96.js";import"./shared-98457d79.js";
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./shared-c59277a4.js";import"./shared-cf1965cb.js";import{h as t}from"./shared-f410644a.js";import"./shared-a8ae24f0.js";import"./shared-5212ef4f.js";import"./foxy-payment-method-card.js";import"./foxy-update-payment-method-form.js";import"./foxy-subscription-form.js";import"./foxy-form-dialog.js";import"./foxy-transactions-table.js";import"./foxy-collection-pages.js";import"./foxy-collection-page.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./shared-
|
|
1
|
+
import"./shared-c59277a4.js";import"./shared-cf1965cb.js";import{h as t}from"./shared-f410644a.js";import"./shared-a8ae24f0.js";import"./shared-5212ef4f.js";import"./foxy-payment-method-card.js";import"./foxy-update-payment-method-form.js";import"./foxy-subscription-form.js";import"./foxy-form-dialog.js";import"./foxy-transactions-table.js";import"./foxy-collection-pages.js";import"./foxy-collection-page.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./shared-8062bbb8.js";import"./foxy-address-card.js";import"./foxy-address-form.js";import"./foxy-spinner.js";import"./foxy-table.js";import"./shared-c066b7fd.js";import{aI as e,_ as s}from"./shared-8f9014ff.js";import{f as r}from"./shared-87e17c02.js";import{L as a,h as o,c as i}from"./shared-ba5c42c7.js";import{C as h}from"./shared-222b23bb.js";import"./shared-dc6e5879.js";import"./shared-cfc6735e.js";import{z as d,S as n,T as l,a as c}from"./shared-5b8c7250.js";import{c as m}from"./shared-4e709717.js";import{S as v}from"./shared-0811ea40.js";import"./shared-41f93e6c.js";import{G as p}from"./shared-b48cd5d3.js";import"./shared-e9f51baa.js";import"./shared-6262e0d6.js";import"./shared-c56c3e1e.js";import"./shared-142df717.js";import"./shared-28cc8aa1.js";import{N as f}from"./shared-c85c1864.js";import{S as g}from"./shared-8f5c8c08.js";import{i as z}from"./shared-53e42a77.js";import"./shared-c3d6bcc0.js";import"./shared-f77994ad.js";import"./shared-cda51ccf.js";import"./shared-cf613436.js";import"./foxy-nucleon-element.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-930e68b7.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-eb349085.js";import"./shared-3a61d8a6.js";import"./shared-91483320.js";import"./shared-d8b880bb.js";import"./shared-2fbfbe12.js";import"./shared-53a5212e.js";import"./shared-8be109a9.js";import"./shared-4ab85bea.js";import"./foxy-swipe-actions.js";import"./foxy-pagination.js";import"./shared-7e28c953.js";import"./shared-56741bad.js";import"./shared-a95a66b8.js";import"./shared-9b290320.js";import"./foxy-copy-to-clipboard.js";import"./shared-affe06c0.js";import"./shared-bab2ea2c.js";import"./shared-53e476fd.js";import"./foxy-template-set-card.js";import"./shared-18707481.js";import"./shared-56278a3c.js";import"./foxy-payment-card-embed.js";import"./shared-7f7d6ceb.js";import"./shared-11de7969.js";import"./shared-5fd5805c.js";import"./shared-e2a5457f.js";import"./shared-e650caf3.js";import"./shared-af6ccc54.js";import"./shared-2061be9a.js";import"./foxy-transaction-card.js";import"./shared-0996f4d0.js";import"./shared-345b07f1.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./shared-1b414966.js";import"./shared-c84333db.js";import"./shared-2fbff8e7.js";import"./shared-96e4f603.js";import"./shared-3ef23488.js";import"./shared-af4f71bf.js";import"./shared-4ed4b075.js";import"./shared-a6b2bd14.js";import"./shared-32a39c0b.js";import"./shared-5dbd66e3.js";import"./shared-091e97f3.js";import"./shared-d0aed1c1.js";import"./shared-b738ee96.js";import"./shared-e9f9face.js";import"./shared-34262bb8.js";import"./shared-62ee726e.js";import"./shared-a08f594b.js";import"./shared-48910b3f.js";let u,b,$,y=t=>t;class H extends a{constructor(){super(...arguments),this.value=0,this.size=0}static get properties(){return{value:{type:Number},size:{type:Number}}}static get styles(){return d.styles}render(){const t=[],e=[];for(let s=0;s<this.size;++s)t.push(o(u||(u=y` <button id="tab-${0}" role="tab" class="${0}" aria-controls="panel-${0}" aria-selected="${0}" @click="${0}" @keydown="${0}"> <slot name="tab-${0}"></slot> </button> `),s,m({"text-l font-medium px-s rounded focus-outline-none focus-shadow-outline":!0,"text-tertiary hover-text-body focus-text-body":this.value!==s}),s,this.value===s,(()=>this.value=s),this.__handleKeyDown,s)),e.push(o(b||(b=y` <slot id="panel-${0}" role="tabpanel" name="panel-${0}" class="${0}" aria-hidden="${0}" aria-labelledby="tab-${0}"> </slot> `),s,s,m({hidden:this.value!==s}),this.value!==s,s));return o($||($=y` <div role="tablist" aria-orientation="horizontal" class="-mx-s mb-s">${0}</div> ${0} `),t,e)}__handleKeyDown(t){if(t.key.startsWith("Arrow")){t.preventDefault();const e=t.target;let s=null;"ArrowRight"===t.key||"ArrowDown"===t.key?s=e.nextElementSibling:"ArrowLeft"!==t.key&&"ArrowUp"!==t.key||(s=e.previousElementSibling),null==s||s.click(),null==s||s.focus()}}}
|
|
2
2
|
/**
|
|
3
3
|
@license
|
|
4
4
|
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-0996f4d0.js";import"./foxy-nucleon-element.js";import"./shared-c066b7fd.js";import{_ as e}from"./shared-8f9014ff.js";import{l as t,u as a}from"./shared-cf613436.js";import{c as s}from"./shared-87e17c02.js";import{C as r}from"./shared-222b23bb.js";import{a as o}from"./shared-5b8c7250.js";import{I as n}from"./shared-56278a3c.js";import{i as d}from"./shared-53e42a77.js";import{h as i}from"./shared-ba5c42c7.js";import"./foxy-spinner.js";import"./shared-c59277a4.js";import"./shared-c3d6bcc0.js";import"./shared-f410644a.js";import"./shared-cf1965cb.js";import"./shared-930e68b7.js";import"./shared-c85c1864.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-4e709717.js";let l,c,p,y
|
|
1
|
+
import"./shared-0996f4d0.js";import"./foxy-nucleon-element.js";import"./shared-c066b7fd.js";import{_ as e}from"./shared-8f9014ff.js";import{l as t,u as a}from"./shared-cf613436.js";import{c as s}from"./shared-87e17c02.js";import{C as r}from"./shared-222b23bb.js";import{a as o}from"./shared-5b8c7250.js";import{I as n}from"./shared-56278a3c.js";import{i as d}from"./shared-53e42a77.js";import{h as i}from"./shared-ba5c42c7.js";import"./foxy-spinner.js";import"./shared-c59277a4.js";import"./shared-c3d6bcc0.js";import"./shared-f410644a.js";import"./shared-cf1965cb.js";import"./shared-930e68b7.js";import"./shared-c85c1864.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-4e709717.js";let l,c,p,u,y=e=>e;const h=r(o(n,"payment-card"));class _ extends h{constructor(){super(...arguments),this.hostedPaymentGatewaysHelper=null,this.paymentGatewaysHelper=null,this.__hostedPaymentGatewaysLoaderId="hostedPaymentGatewaysLoader",this.__paymentGatewaysLoaderId="paymentGatewaysLoader",this.__transactionLoaderId="transactionLoader",this.__storeLoaderId="storeLoader"}static get properties(){return e(e({},super.properties),{},{hostedPaymentGatewaysHelper:{attribute:"hosted-payment-gateways-helper"},paymentGatewaysHelper:{attribute:"payment-gateways-helper"}})}renderBody(){var e,s,r,o,n,h,_,m,f;const v=this.data,x=`${null!==(e=null==v?void 0:v.amount)&&void 0!==e?e:""} ${this.__currencyCode}`,w={currencyDisplay:this.__currencyDisplay,amount:x},$=null!==(r=null===(s=this.data)||void 0===s?void 0:s.fraud_protection_score)&&void 0!==r?r:0,b=$>0?"text-error":"text-success",L=$>0?"bg-error-10":"bg-success-10",j=(null!==(o=null==v?void 0:v.cc_type)&&void 0!==o?o:"unknown").toLowerCase(),g=null===(n=null==v?void 0:v.cc_exp_year)||void 0===n?void 0:n.substring(2),G=null==v?void 0:v.cc_exp_month,I=null===(h=null==v?void 0:v.cc_number_masked)||void 0===h?void 0:h.replace(/x/gi,"");return i(l||(l=y` <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <p class="leading-s"> <span class="block font-medium text-m" data-testid="line-1"> <foxy-i18n .options="${0}" infer="" key="price"></foxy-i18n> <span> • </span> <foxy-i18n .options="${0}" infer="" key="date"></foxy-i18n> </span> ${0} ${0} <span class="mt-s flex space-x-s overflow-auto"> ${0} <foxy-i18n class="truncate flex font-medium h-xs items-center px-s rounded-s text-s ${0} ${0}" infer="" key="fraud_risk" .options="${0}"> </foxy-i18n> </span> </p> `),d(null!==(_=this.hostedPaymentGatewaysHelper)&&void 0!==_?_:void 0),this.__hostedPaymentGatewaysLoaderId,(()=>this.requestUpdate()),d(null!==(m=this.paymentGatewaysHelper)&&void 0!==m?m:void 0),this.__paymentGatewaysLoaderId,(()=>this.requestUpdate()),d(null==v?void 0:v._links["fx:transaction"].href),this.__transactionLoaderId,(()=>this.requestUpdate()),d(this.__canReadStore?null==v?void 0:v._links["fx:store"].href:void 0),this.__storeLoaderId,(()=>this.requestUpdate()),w,{value:null==v?void 0:v.date_created},this.__gatewayName?i(c||(c=y` <span class="block text-s text-secondary" data-testid="gateway"> ${0} </span> `),this.__gatewayName):"",["processor_response","paypal_payer_id","third_party_id","purchase_order"].map((e=>{if(!(null==v?void 0:v[e]))return;return i(p||(p=y`<foxy-i18n class="${0}" infer="" key="${0}" .options="${0}"></foxy-i18n>`),"block text-s text-tertiary",e,v)})),G&&g&&I?i(u||(u=y` <span class="truncate flex items-center h-xs rounded-s overflow-hidden bg-contrast-5" data-testid="card-info"> <span class="h-xs">${0}</span> <span class="font-medium px-s">•••• ${0} ${0}/${0}</span> </span> `),null!==(f=t[j])&&void 0!==f?f:a,I,G,g):"",b,L,{score:$})}get isBodyReady(){if(!super.isBodyReady)return!1;if(!this.__currencyCode)return!1;if(!this.__currencyDisplay)return!1;if(this.__gatewayName)return!0;const e=(e,t)=>!e||!!(null==t?void 0:t.data)||!!(null==t?void 0:t.in("fail"));return e(this.hostedPaymentGatewaysHelper,this.__hostedPaymentGatewaysLoader)&&e(this.paymentGatewaysHelper,this.__paymentGatewaysLoader)}get __hostedPaymentGatewaysLoader(){return this.renderRoot.querySelector(`#${this.__hostedPaymentGatewaysLoaderId}`)}get __paymentGatewaysLoader(){return this.renderRoot.querySelector(`#${this.__paymentGatewaysLoaderId}`)}get __transactionLoader(){return this.renderRoot.querySelector(`#${this.__transactionLoaderId}`)}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}get __canReadStore(){return s(this.currentUserScope,"stores")}get __currencyDisplay(){var e;const t=null===(e=this.__storeLoader)||void 0===e?void 0:e.data;return t||this.__canReadStore?t?t.use_international_currency_symbol?"code":"symbol":void 0:"symbol"}get __currencyCode(){var e,t;return null===(t=null===(e=this.__transactionLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.currency_code}get __gatewayName(){var e,t,a,s,r,o;const n=null===(e=this.data)||void 0===e?void 0:e.gateway_type;if(n){const e=null===(a=null===(t=this.__paymentGatewaysLoader)||void 0===t?void 0:t.data)||void 0===a?void 0:a.values[n],d=null===(r=null===(s=this.__hostedPaymentGatewaysLoader)||void 0===s?void 0:s.data)||void 0===r?void 0:r.values[n];return null!==(o=null==e?void 0:e.name)&&void 0!==o?o:null==d?void 0:d.name}}}customElements.define("foxy-payment-card",_);export{_ as PaymentCard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./shared-a6b2bd14.js";import"./shared-af4f71bf.js";import"./shared-32a39c0b.js";import"./shared-091e97f3.js";import{I as e}from"./shared-9b290320.js";import{a as t}from"./shared-4ab85bea.js";import"./shared-c066b7fd.js";import{i as s}from"./shared-53e42a77.js";import{h as o}from"./shared-ba5c42c7.js";import{c as r,_ as n,B as i}from"./shared-8f9014ff.js";import{S as a,a as l}from"./shared-5b8c7250.js";import{v as d}from"./shared-b738ee96.js";import{c}from"./shared-4e709717.js";let h,p=e=>e;customElements.define("foxy-internal-customer-form-legal-notice-control",class extends t{renderControl(){var e,t;const r=this.nucleon;return o(h||(h=p` <p class="leading-s text-xs text-secondary"> <foxy-i18n infer="" key="text"></foxy-i18n> <a class="font-medium text-body rounded hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50" target="_blank" href="${0}" rel="noopener noreferrer"> <foxy-i18n infer="" key="link"></foxy-i18n> </a> </p> `),s(null===(t=null===(e=null==r?void 0:r.settings)||void 0===e?void 0:e.tos_checkbox_settings)||void 0===t?void 0:t.url))}});var u=r((function(e){!function(){const t=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],s=(e,s=t,o="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=e||"";s[0].minDiversity=0,s[0].minLength=0;const n=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];o&&n.push({regex:`[${o}]`,message:"symbol"});let i={};i.contains=n.filter((e=>new RegExp(`${e.regex}`).test(r))).map((e=>e.message)),i.length=r.length;let a=s.filter((e=>i.contains.length>=e.minDiversity)).filter((e=>i.length>=e.minLength)).sort(((e,t)=>t.id-e.id)).map((e=>({id:e.id,value:e.value})));return Object.assign(i,a[0]),i};e.exports={passwordStrength:s,defaultOptions:t}}()}));let m,f,_=e=>e;const g=a(l(e,"customer-form")),v=u.passwordStrength;class x extends g{constructor(){super(...arguments),this.passwordless=!1,this.settings=null,this.__passwordGeneratorOptions={checkStrength:e=>v(e).id>=2},this.__isAnonymousGetValue=()=>{var e;return!1===(null===(e=this.form)||void 0===e?void 0:e.is_anonymous)?"false":"true"},this.__isAnonymousSetValue=e=>{const t="true"===e;this.edit({is_anonymous:t}),t&&this.form.password&&this.edit({password:""}),t&&this.form.password_old&&this.edit({password_old:""}),t&&this.form.forgot_password&&this.edit({forgot_password:""})},this.__isAnonymousOptions=[{value:"true",label:"option_true"},{value:"false",label:"option_false"}],this.__refreshInterval=null}static get scopedElements(){return{"foxy-internal-customer-form-legal-notice-control":customElements.get("foxy-internal-customer-form-legal-notice-control"),"foxy-internal-radio-group-control":customElements.get("foxy-internal-radio-group-control"),"foxy-internal-timestamps-control":customElements.get("foxy-internal-timestamps-control"),"foxy-internal-password-control":customElements.get("foxy-internal-password-control"),"foxy-internal-submit-control":customElements.get("foxy-internal-submit-control"),"foxy-internal-delete-control":customElements.get("foxy-internal-delete-control"),"foxy-internal-text-control":customElements.get("foxy-internal-text-control"),"foxy-internal-undo-control":customElements.get("foxy-internal-undo-control"),"foxy-copy-to-clipboard":customElements.get("foxy-copy-to-clipboard"),"foxy-spinner":customElements.get("foxy-spinner"),"vcf-tooltip":customElements.get("vcf-tooltip"),"foxy-i18n":customElements.get("foxy-i18n"),"h-captcha":customElements.get("h-captcha"),"vaadin-button":customElements.get("vaadin-button")}}static get properties(){return n(n({},super.properties),{},{passwordless:{type:Boolean},settings:{type:Object}})}static get v8n(){return[({password:e,_links:t,is_anonymous:s=!0},o)=>!!o.passwordless||(!!(t||s||e)||"password:v8n_required"),({password_old:e,password:t,email:s,_links:o},r)=>{var n;return!o||(void 0===(null===(n=r.settings)||void 0===n?void 0:n.sign_up)||(!((t||r.__isEmailChanged(s))&&!e)||"password-old:v8n_required"))},({first_name:e})=>!e||e.length<=50||"first-name:v8n_too_long",({last_name:e})=>!e||e.length<=50||"last-name:v8n_too_long",({password:e})=>!e||v(e).id>=2||"password:v8n_too_weak",({password:e})=>!e||e.length<=50||"password:v8n_too_long",({tax_id:e})=>!e||e.length<=50||"tax-id:v8n_too_long",({email:e})=>e&&e.length>0||"email:v8n_required",({email:e})=>!e||e.length<=100||"email:v8n_too_long",({email:e})=>!e||d(e)||"email:v8n_invalid_email"]}get scopeCollection(){return"customers"}get hiddenSelector(){const e=new Set(super.hiddenSelector.toString().split(" "));return this.settings?(e.add("forgot-password"),e.add("is-anonymous"),this.form.password||this.__isEmailChanged(this.form.email)||e.add("password-old"),"none"===this.settings.tos_checkbox_settings.usage&&e.add("legal-notice")):(!1!==this.form.is_anonymous&&(e.add("forgot-password"),e.add("password")),e.add("password-old"),e.add("legal-notice")),this.href&&(e.add("is-anonymous"),e.add("legal-notice")),new i(Array.from(e).join(" ").trim())}get headerTitleOptions(){var e,t;const s=this.data;return!s||(null===(e=s.first_name)||void 0===e?void 0:e.trim())||(null===(t=s.last_name)||void 0===t?void 0:t.trim())?super.headerTitleOptions:n(n({},super.headerTitleOptions),{},{context:"no_name"})}get headerSubtitleKey(){var e;return(null===(e=this.data)||void 0===e?void 0:e.is_anonymous)?"subtitle_anonymous":"subtitle_registered"}get headerSubtitleOptions(){return n(n({},super.headerSubtitleOptions),{},{id:this.headerCopyIdValue})}disconnectedCallback(){super.disconnectedCallback();const e=this.__refreshInterval;e&&clearInterval(e)}connectedCallback(){super.connectedCallback();const e=setInterval((()=>this.requestUpdate()),6e4);this.__refreshInterval=e}renderBody(){var e,t,s,r;const n=this.hiddenSelector.matches("first-name",!0),i=this.hiddenSelector.matches("last-name",!0);return o(m||(m=_` ${0} <div class="${0}"> <foxy-internal-text-control infer="first-name"></foxy-internal-text-control> <foxy-internal-text-control infer="last-name"></foxy-internal-text-control> </div> <foxy-internal-text-control helper-text="${0}" infer="email"> </foxy-internal-text-control> <foxy-internal-radio-group-control infer="is-anonymous" .getValue="${0}" .setValue="${0}" .options="${0}"> </foxy-internal-radio-group-control> <foxy-internal-password-control placeholder="${0}" helper-text="${0}" infer="password" show-generator .generatorOptions="${0}"> </foxy-internal-password-control> <foxy-internal-password-control infer="password-old"></foxy-internal-password-control> <foxy-internal-password-control helper-text="${0}" infer="forgot-password" show-generator> </foxy-internal-password-control> <foxy-internal-text-control infer="tax-id"></foxy-internal-text-control> <foxy-internal-customer-form-legal-notice-control infer="legal-notice"> </foxy-internal-customer-form-legal-notice-control> ${0} ${0} `),this.renderHeader(),c({"grid-cols-2":!n&&!i,hidden:n&&i,"gap-m":!0,grid:!n||!i}),this.__emailHelperText,this.__isAnonymousGetValue,this.__isAnonymousSetValue,this.__isAnonymousOptions,this.__passwordPlaceholder,this.__passwordHelperText,this.__passwordGeneratorOptions,this.__forgotPasswordHelperText,!this.data&&(null===(t=null===(e=this.settings)||void 0===e?void 0:e.sign_up)||void 0===t?void 0:t.enabled)&&"hcaptcha"===(null===(r=null===(s=this.settings)||void 0===s?void 0:s.sign_up)||void 0===r?void 0:r.verification.type)?o(f||(f=_` <h-captcha site-key="${0}" class="hidden" size="invisible" hl="${0}" @verified="${0}"> </h-captcha> `),this.settings.sign_up.verification.site_key,this.lang,(({token:e})=>{this.edit({verification:{type:"hcaptcha",token:e}}),super.submit()})):"",super.renderBody())}submit(){var e,t,s,o,r;"hcaptcha"!==(null===(s=null===(t=null===(e=this.settings)||void 0===e?void 0:e.sign_up)||void 0===t?void 0:t.verification)||void 0===s?void 0:s.type)||this.data?super.submit():(null===(o=this.__hcaptcha)||void 0===o||o.reset(),null===(r=this.__hcaptcha)||void 0===r||r.execute())}async _sendPatch(e){const t=await super._sendPatch(e);if(e.password){const e={key:"password_change_success",options:{email:t.email}};this.status=e}return t}async _sendGet(){return this.status=null,await super._sendGet()}async _fetch(...e){try{return await super._fetch(...e)}catch(e){let t;try{t=(await e.json())._embedded["fx:errors"][0].message}catch(t){throw e}throw"Conflict"===t||t.startsWith("This email address is already in use")?["error:email_already_used"]:t.startsWith("Customer registration is disabled")?["error:registration_disabled"]:t.startsWith("Client verification failed")?["error:verification_failed"]:t.startsWith("Provided password is incorrect")?["error:old_password_incorrect"]:t.startsWith("password_old is required")?["error:old_password_required"]:e}}get __forgotPasswordHelperText(){var e,t;const s=null===(e=this.data)||void 0===e?void 0:e.forgot_password_timestamp,o="forgot-password.helper_text";if((null===(t=this.data)||void 0===t?void 0:t.forgot_password)&&s){const e=new Date(new Date(s).getTime()+18e5),t=Math.floor((e.getTime()-Date.now())/1e3/60);return t<=0?this.t(`${o}_expired_on`,{expiresOn:e}):this.t(`${o}_expires_in`,{expiresInMin:`${t}minutes`})}return this.t(o)}get __passwordPlaceholder(){return this.data?this.t("password.placeholder_new"):this.t("password.placeholder")}get __passwordHelperText(){return this.data?this.t("password.helper_text_new"):this.t("password.helper_text")}get __emailHelperText(){var e;return(null===(e=this.data)||void 0===e?void 0:e.last_login_date)?this.t("email.helper_text_last_login_date",{date:this.data.last_login_date}):this.t("email.helper_text")}get __hcaptcha(){return this.renderRoot.querySelector("h-captcha")}__isEmailChanged(e){var t;const s=null===(t=this.data)||void 0===t?void 0:t.email;return!(!s||void 0===e)&&e.trim().toLowerCase()!==s.trim().toLowerCase()}}customElements.define("foxy-customer-form",x);export{x as C,u};
|
|
@@ -1411,7 +1411,6 @@
|
|
|
1411
1411
|
"paypal_payer_id": "PayPal Payer ID {{ paypal_payer_id }}",
|
|
1412
1412
|
"third_party_id": "External ID {{ third_party_id }}",
|
|
1413
1413
|
"price": "{{amount, price}}",
|
|
1414
|
-
"unknown": "Unknown",
|
|
1415
1414
|
"spinner": {
|
|
1416
1415
|
"loading_busy": "Loading",
|
|
1417
1416
|
"loading_empty": "No payments",
|
|
@@ -873,7 +873,7 @@
|
|
|
873
873
|
"password-old": {
|
|
874
874
|
"label": "Old password",
|
|
875
875
|
"placeholder": "",
|
|
876
|
-
"helper_text": "Enter
|
|
876
|
+
"helper_text": "Enter your current password to change your email or password. If you're a store admin, you can leave this field blank.",
|
|
877
877
|
"v8n_required": "Please fill out this field."
|
|
878
878
|
},
|
|
879
879
|
"forgot-password": {
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"old_password_incorrect": "The old password you entered is incorrect. Please try again.",
|
|
31
31
|
"registration_disabled": "Customer registration is disabled for this store. If you're seeing this message as a customer, please contact the store owner.",
|
|
32
32
|
"verification_failed": "Client verification failed. If you are seeing this message as a customer, please contact the store owner.",
|
|
33
|
-
"email_already_used": "This email is already in use. Please use a different email."
|
|
33
|
+
"email_already_used": "This email is already in use. Please use a different email.",
|
|
34
|
+
"old_password_required": "Enter your current password to change your email or password."
|
|
34
35
|
},
|
|
35
36
|
"first-name": {
|
|
36
37
|
"label": "First name",
|
|
@@ -78,7 +79,7 @@
|
|
|
78
79
|
"password-old": {
|
|
79
80
|
"label": "Old password",
|
|
80
81
|
"placeholder": "",
|
|
81
|
-
"helper_text": "Enter
|
|
82
|
+
"helper_text": "Enter your current password to change your email or password. If you're a store admin, you can leave this field blank.",
|
|
82
83
|
"v8n_required": "Please fill out this field."
|
|
83
84
|
},
|
|
84
85
|
"forgot-password": {
|
|
@@ -769,7 +769,8 @@
|
|
|
769
769
|
},
|
|
770
770
|
"error": {
|
|
771
771
|
"old_password_incorrect": "The old password you entered is incorrect. Please try again.",
|
|
772
|
-
"email_already_used": "This email is already in use. Please use a different email."
|
|
772
|
+
"email_already_used": "This email is already in use. Please use a different email.",
|
|
773
|
+
"old_password_required": "Enter your current password to change your email or password."
|
|
773
774
|
},
|
|
774
775
|
"first-name": {
|
|
775
776
|
"label": "First name",
|
|
@@ -810,7 +811,7 @@
|
|
|
810
811
|
"password-old": {
|
|
811
812
|
"label": "Old password",
|
|
812
813
|
"placeholder": "",
|
|
813
|
-
"helper_text": "Enter your
|
|
814
|
+
"helper_text": "Enter your current password to confirm this change.",
|
|
814
815
|
"v8n_required": "Please fill out this field."
|
|
815
816
|
},
|
|
816
817
|
"timestamps": {
|
|
@@ -1040,7 +1040,6 @@
|
|
|
1040
1040
|
"paypal_payer_id": "PayPal Payer ID {{ paypal_payer_id }}",
|
|
1041
1041
|
"third_party_id": "External ID {{ third_party_id }}",
|
|
1042
1042
|
"price": "{{amount, price}}",
|
|
1043
|
-
"unknown": "Unknown",
|
|
1044
1043
|
"spinner": {
|
|
1045
1044
|
"loading_busy": "Loading",
|
|
1046
1045
|
"loading_empty": "No payments",
|
|
@@ -45,5 +45,7 @@ export declare class CustomerForm extends Base<Data> {
|
|
|
45
45
|
private get __passwordHelperText();
|
|
46
46
|
private get __emailHelperText();
|
|
47
47
|
private get __hcaptcha();
|
|
48
|
+
/** True when `email` differs from the saved one. Customer API asks for the current password to change it. */
|
|
49
|
+
private __isEmailChanged;
|
|
48
50
|
}
|
|
49
51
|
export {};
|
|
@@ -77,13 +77,15 @@ export class CustomerForm extends Base {
|
|
|
77
77
|
return true;
|
|
78
78
|
return !_links && !is_anonymous && !password ? 'password:v8n_required' : true;
|
|
79
79
|
},
|
|
80
|
-
({ password_old, password, _links }, host) => {
|
|
80
|
+
({ password_old, password, email, _links }, host) => {
|
|
81
81
|
var _a;
|
|
82
82
|
if (!_links)
|
|
83
83
|
return true;
|
|
84
84
|
if (((_a = host.settings) === null || _a === void 0 ? void 0 : _a.sign_up) === undefined)
|
|
85
85
|
return true;
|
|
86
|
-
return password && !password_old
|
|
86
|
+
return (password || host.__isEmailChanged(email)) && !password_old
|
|
87
|
+
? 'password-old:v8n_required'
|
|
88
|
+
: true;
|
|
87
89
|
},
|
|
88
90
|
({ first_name: v }) => !v || v.length <= 50 || 'first-name:v8n_too_long',
|
|
89
91
|
({ last_name: v }) => !v || v.length <= 50 || 'last-name:v8n_too_long',
|
|
@@ -103,7 +105,7 @@ export class CustomerForm extends Base {
|
|
|
103
105
|
if (this.settings) {
|
|
104
106
|
hidden.add('forgot-password');
|
|
105
107
|
hidden.add('is-anonymous');
|
|
106
|
-
if (!this.form.password)
|
|
108
|
+
if (!this.form.password && !this.__isEmailChanged(this.form.email))
|
|
107
109
|
hidden.add('password-old');
|
|
108
110
|
if (this.settings.tos_checkbox_settings.usage === 'none')
|
|
109
111
|
hidden.add('legal-notice');
|
|
@@ -265,6 +267,9 @@ export class CustomerForm extends Base {
|
|
|
265
267
|
else if (message.startsWith('Provided password is incorrect')) {
|
|
266
268
|
throw ['error:old_password_incorrect'];
|
|
267
269
|
}
|
|
270
|
+
else if (message.startsWith('password_old is required')) {
|
|
271
|
+
throw ['error:old_password_required'];
|
|
272
|
+
}
|
|
268
273
|
else {
|
|
269
274
|
throw err;
|
|
270
275
|
}
|
|
@@ -300,5 +305,13 @@ export class CustomerForm extends Base {
|
|
|
300
305
|
get __hcaptcha() {
|
|
301
306
|
return this.renderRoot.querySelector('h-captcha');
|
|
302
307
|
}
|
|
308
|
+
/** True when `email` differs from the saved one. Customer API asks for the current password to change it. */
|
|
309
|
+
__isEmailChanged(email) {
|
|
310
|
+
var _a;
|
|
311
|
+
const saved = (_a = this.data) === null || _a === void 0 ? void 0 : _a.email;
|
|
312
|
+
if (!saved || email === undefined)
|
|
313
|
+
return false;
|
|
314
|
+
return email.trim().toLowerCase() !== saved.trim().toLowerCase();
|
|
315
|
+
}
|
|
303
316
|
}
|
|
304
317
|
//# sourceMappingURL=CustomerForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerForm/CustomerForm.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY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C,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC;YAChF,IAAI,YAAY,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,aAAa,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;YAC7E,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,aAAa,EAAE,EAAE,YAAY,EAAE,GAAG,YAAY,SAAS,EAAE,CAAC,CAAC;SACpF;aAAM;YACL,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACxB;IACH,CAAC;IAED,IAAY,qBAAqB;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC;IACzF,CAAC;IAED,IAAY,oBAAoB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC;IACzF,CAAC;IAED,IAAY,iBAAiB;;QAC3B,OAAO,OAAA,IAAI,CAAC,IAAI,0CAAE,eAAe,EAC/B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,mCAAmC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAClF,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAClC,CAAC;IAED,IAAY,UAAU;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAA8B,WAAW,CAAC,CAAC;IACjF,CAAC;CACF","sourcesContent":["import type { ScopeCollection } from '../../../utils/user-scope';\nimport type { VanillaHCaptchaWebComponent } from 'vanilla-hcaptcha';\nimport type { Data, Settings } from './types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport type { GeneratorOptions } from '../../internal/InternalPasswordControl/generateRandomPassword';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\n\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { validate as isEmail } from 'email-validator';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nimport checkPasswordStrength from 'check-password-strength';\n\nconst NS = 'customer-form';\nconst Base = ScopedElementsMixin(TranslatableMixin(InternalForm, NS));\nconst passwordStrength = checkPasswordStrength.passwordStrength;\n\n/**\n * Form element for creating or editing customers.\n *\n * @element foxy-customer-form\n * @since 1.2.0\n */\nexport class CustomerForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-customer-form-legal-notice-control': customElements.get(\n 'foxy-internal-customer-form-legal-notice-control'\n ),\n 'foxy-internal-radio-group-control': customElements.get('foxy-internal-radio-group-control'),\n 'foxy-internal-timestamps-control': customElements.get('foxy-internal-timestamps-control'),\n 'foxy-internal-password-control': customElements.get('foxy-internal-password-control'),\n 'foxy-internal-submit-control': customElements.get('foxy-internal-submit-control'),\n 'foxy-internal-delete-control': customElements.get('foxy-internal-delete-control'),\n 'foxy-internal-text-control': customElements.get('foxy-internal-text-control'),\n 'foxy-internal-undo-control': customElements.get('foxy-internal-undo-control'),\n 'foxy-copy-to-clipboard': customElements.get('foxy-copy-to-clipboard'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'vcf-tooltip': customElements.get('vcf-tooltip'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'h-captcha': customElements.get('h-captcha'),\n 'vaadin-button': customElements.get('vaadin-button'),\n };\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n passwordless: { type: Boolean },\n settings: { type: Object },\n };\n }\n\n static get v8n(): NucleonV8N<Data, CustomerForm> {\n return [\n ({ password, _links, is_anonymous = true }, host) => {\n if (host.passwordless) return true;\n return !_links && !is_anonymous && !password ? 'password:v8n_required' : true;\n },\n ({ password_old, password, _links }, host) => {\n if (!_links) return true;\n if (host.settings?.sign_up === undefined) return true;\n return password && !password_old ? 'password-old:v8n_required' : true;\n },\n ({ first_name: v }) => !v || v.length <= 50 || 'first-name:v8n_too_long',\n ({ last_name: v }) => !v || v.length <= 50 || 'last-name:v8n_too_long',\n ({ password: v }) => !v || passwordStrength(v).id >= 2 || 'password:v8n_too_weak',\n ({ password: v }) => !v || v.length <= 50 || 'password:v8n_too_long',\n ({ tax_id: v }) => !v || v.length <= 50 || 'tax-id:v8n_too_long',\n ({ email: v }) => (v && v.length > 0) || 'email:v8n_required',\n ({ email: v }) => !v || v.length <= 100 || 'email:v8n_too_long',\n ({ email: v }) => !v || isEmail(v) || 'email:v8n_invalid_email',\n ];\n }\n\n /** If true, won't require password when creating a customer. */\n passwordless = false;\n\n /** Full `fx:customer_portal_settings` resource from Customer API. If present, switches this element into the Customer API mode, enabling client verification. */\n settings: Settings | null = null;\n\n private readonly __passwordGeneratorOptions: GeneratorOptions = {\n checkStrength: value => passwordStrength(value).id >= 2,\n };\n\n private readonly __isAnonymousGetValue = () => {\n return this.form?.is_anonymous === false ? 'false' : 'true';\n };\n\n private readonly __isAnonymousSetValue = (newValue: string) => {\n const isAnonymous = newValue === 'true';\n this.edit({ is_anonymous: isAnonymous });\n if (isAnonymous && this.form.password) this.edit({ password: '' });\n if (isAnonymous && this.form.password_old) this.edit({ password_old: '' });\n if (isAnonymous && this.form.forgot_password) this.edit({ forgot_password: '' });\n };\n\n private readonly __isAnonymousOptions = [\n { value: 'true', label: 'option_true' },\n { value: 'false', label: 'option_false' },\n ];\n\n private __refreshInterval: NodeJS.Timeout | null = null;\n\n get scopeCollection(): ScopeCollection | null {\n return 'customers';\n }\n\n get hiddenSelector(): BooleanSelector {\n const hidden = new Set<string>(super.hiddenSelector.toString().split(' '));\n\n if (this.settings) {\n hidden.add('forgot-password');\n hidden.add('is-anonymous');\n if (!this.form.password) hidden.add('password-old');\n if (this.settings.tos_checkbox_settings.usage === 'none') hidden.add('legal-notice');\n } else {\n if (this.form.is_anonymous !== false) {\n hidden.add('forgot-password');\n hidden.add('password');\n }\n hidden.add('password-old');\n hidden.add('legal-notice');\n }\n\n if (this.href) {\n hidden.add('is-anonymous');\n hidden.add('legal-notice');\n }\n\n return new BooleanSelector(Array.from(hidden).join(' ').trim());\n }\n\n get headerTitleOptions(): Record<string, unknown> {\n const data = this.data;\n if (!data || data.first_name?.trim() || data.last_name?.trim()) return super.headerTitleOptions;\n return { ...super.headerTitleOptions, context: 'no_name' };\n }\n\n get headerSubtitleKey(): string {\n return this.data?.is_anonymous ? 'subtitle_anonymous' : 'subtitle_registered';\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n return { ...super.headerSubtitleOptions, id: this.headerCopyIdValue };\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n const interval = this.__refreshInterval;\n if (interval) clearInterval(interval);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n const interval = setInterval(() => this.requestUpdate(), 60 * 1000);\n this.__refreshInterval = interval;\n }\n\n renderBody(): TemplateResult {\n const isFirstNameHidden = this.hiddenSelector.matches('first-name', true);\n const isLastNameHidden = this.hiddenSelector.matches('last-name', true);\n\n return html`\n ${this.renderHeader()}\n\n <div\n class=${classMap({\n 'grid-cols-2': !isFirstNameHidden && !isLastNameHidden,\n 'hidden': isFirstNameHidden && isLastNameHidden,\n 'gap-m': true,\n 'grid': !isFirstNameHidden || !isLastNameHidden,\n })}\n >\n <foxy-internal-text-control infer=\"first-name\"></foxy-internal-text-control>\n <foxy-internal-text-control infer=\"last-name\"></foxy-internal-text-control>\n </div>\n\n <foxy-internal-text-control helper-text=${this.__emailHelperText} infer=\"email\">\n </foxy-internal-text-control>\n\n <foxy-internal-radio-group-control\n infer=\"is-anonymous\"\n .getValue=${this.__isAnonymousGetValue}\n .setValue=${this.__isAnonymousSetValue}\n .options=${this.__isAnonymousOptions}\n >\n </foxy-internal-radio-group-control>\n\n <foxy-internal-password-control\n placeholder=${this.__passwordPlaceholder}\n helper-text=${this.__passwordHelperText}\n infer=\"password\"\n show-generator\n .generatorOptions=${this.__passwordGeneratorOptions}\n >\n </foxy-internal-password-control>\n\n <foxy-internal-password-control infer=\"password-old\"></foxy-internal-password-control>\n\n <foxy-internal-password-control\n helper-text=${this.__forgotPasswordHelperText}\n infer=\"forgot-password\"\n show-generator\n >\n </foxy-internal-password-control>\n\n <foxy-internal-text-control infer=\"tax-id\"></foxy-internal-text-control>\n\n <foxy-internal-customer-form-legal-notice-control infer=\"legal-notice\">\n </foxy-internal-customer-form-legal-notice-control>\n\n ${!this.data &&\n this.settings?.sign_up?.enabled &&\n this.settings?.sign_up?.verification.type === 'hcaptcha'\n ? html`\n <h-captcha\n site-key=${this.settings.sign_up.verification.site_key}\n class=\"hidden\"\n size=\"invisible\"\n hl=${this.lang}\n @verified=${({ token }: Record<'token' | 'eKey', string>) => {\n this.edit({ verification: { type: 'hcaptcha', token } });\n super.submit();\n }}\n >\n </h-captcha>\n `\n : ''}\n ${super.renderBody()}\n `;\n }\n\n submit(): void {\n if (this.settings?.sign_up?.verification?.type === 'hcaptcha' && !this.data) {\n this.__hcaptcha?.reset();\n this.__hcaptcha?.execute();\n } else {\n super.submit();\n }\n }\n\n protected async _sendPatch(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPatch(edits);\n\n if (edits.password) {\n const status = { key: 'password_change_success', options: { email: data.email } };\n this.status = status;\n }\n\n return data;\n }\n\n protected async _sendGet(): Promise<Data> {\n this.status = null;\n return await super._sendGet();\n }\n\n protected async _fetch<TResult = Data>(...args: Parameters<Window['fetch']>): Promise<TResult> {\n try {\n return await super._fetch(...args);\n } catch (err) {\n let message;\n\n try {\n message = (await (err as Response).json())._embedded['fx:errors'][0].message;\n } catch {\n throw err;\n }\n\n if (message === 'Conflict' || message.startsWith('This email address is already in use')) {\n throw ['error:email_already_used'];\n } else if (message.startsWith('Customer registration is disabled')) {\n throw ['error:registration_disabled'];\n } else if (message.startsWith('Client verification failed')) {\n throw ['error:verification_failed'];\n } else if (message.startsWith('Provided password is incorrect')) {\n throw ['error:old_password_incorrect'];\n } else {\n throw err;\n }\n }\n }\n\n private get __forgotPasswordHelperText() {\n const createdOn = this.data?.forgot_password_timestamp;\n const password = this.data?.forgot_password;\n const i18nKey = 'forgot-password.helper_text';\n\n if (password && createdOn) {\n const expiresOn = new Date(new Date(createdOn).getTime() + 30 * 60 * 1000);\n const expiresInMin = Math.floor((expiresOn.getTime() - Date.now()) / 1000 / 60);\n if (expiresInMin <= 0) return this.t(`${i18nKey}_expired_on`, { expiresOn });\n return this.t(`${i18nKey}_expires_in`, { expiresInMin: `${expiresInMin}minutes` });\n } else {\n return this.t(i18nKey);\n }\n }\n\n private get __passwordPlaceholder() {\n return this.data ? this.t('password.placeholder_new') : this.t('password.placeholder');\n }\n\n private get __passwordHelperText() {\n return this.data ? this.t('password.helper_text_new') : this.t('password.helper_text');\n }\n\n private get __emailHelperText() {\n return this.data?.last_login_date\n ? this.t('email.helper_text_last_login_date', { date: this.data.last_login_date })\n : this.t('email.helper_text');\n }\n\n private get __hcaptcha() {\n return this.renderRoot.querySelector<VanillaHCaptchaWebComponent>('h-captcha');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CustomerForm.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerForm/CustomerForm.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC;A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CAAC;IACjF,CAAC;IAED,6GAA6G;IACrG,gBAAgB,CAAC,KAAyB;;QAChD,MAAM,KAAK,SAAG,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAC;QAC/B,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAChD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACnE,CAAC;CACF","sourcesContent":["import type { ScopeCollection } from '../../../utils/user-scope';\nimport type { VanillaHCaptchaWebComponent } from 'vanilla-hcaptcha';\nimport type { Data, Settings } from './types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport type { GeneratorOptions } from '../../internal/InternalPasswordControl/generateRandomPassword';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\n\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { validate as isEmail } from 'email-validator';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nimport checkPasswordStrength from 'check-password-strength';\n\nconst NS = 'customer-form';\nconst Base = ScopedElementsMixin(TranslatableMixin(InternalForm, NS));\nconst passwordStrength = checkPasswordStrength.passwordStrength;\n\n/**\n * Form element for creating or editing customers.\n *\n * @element foxy-customer-form\n * @since 1.2.0\n */\nexport class CustomerForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-customer-form-legal-notice-control': customElements.get(\n 'foxy-internal-customer-form-legal-notice-control'\n ),\n 'foxy-internal-radio-group-control': customElements.get('foxy-internal-radio-group-control'),\n 'foxy-internal-timestamps-control': customElements.get('foxy-internal-timestamps-control'),\n 'foxy-internal-password-control': customElements.get('foxy-internal-password-control'),\n 'foxy-internal-submit-control': customElements.get('foxy-internal-submit-control'),\n 'foxy-internal-delete-control': customElements.get('foxy-internal-delete-control'),\n 'foxy-internal-text-control': customElements.get('foxy-internal-text-control'),\n 'foxy-internal-undo-control': customElements.get('foxy-internal-undo-control'),\n 'foxy-copy-to-clipboard': customElements.get('foxy-copy-to-clipboard'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'vcf-tooltip': customElements.get('vcf-tooltip'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'h-captcha': customElements.get('h-captcha'),\n 'vaadin-button': customElements.get('vaadin-button'),\n };\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n passwordless: { type: Boolean },\n settings: { type: Object },\n };\n }\n\n static get v8n(): NucleonV8N<Data, CustomerForm> {\n return [\n ({ password, _links, is_anonymous = true }, host) => {\n if (host.passwordless) return true;\n return !_links && !is_anonymous && !password ? 'password:v8n_required' : true;\n },\n ({ password_old, password, email, _links }, host) => {\n if (!_links) return true;\n if (host.settings?.sign_up === undefined) return true;\n return (password || host.__isEmailChanged(email)) && !password_old\n ? 'password-old:v8n_required'\n : true;\n },\n ({ first_name: v }) => !v || v.length <= 50 || 'first-name:v8n_too_long',\n ({ last_name: v }) => !v || v.length <= 50 || 'last-name:v8n_too_long',\n ({ password: v }) => !v || passwordStrength(v).id >= 2 || 'password:v8n_too_weak',\n ({ password: v }) => !v || v.length <= 50 || 'password:v8n_too_long',\n ({ tax_id: v }) => !v || v.length <= 50 || 'tax-id:v8n_too_long',\n ({ email: v }) => (v && v.length > 0) || 'email:v8n_required',\n ({ email: v }) => !v || v.length <= 100 || 'email:v8n_too_long',\n ({ email: v }) => !v || isEmail(v) || 'email:v8n_invalid_email',\n ];\n }\n\n /** If true, won't require password when creating a customer. */\n passwordless = false;\n\n /** Full `fx:customer_portal_settings` resource from Customer API. If present, switches this element into the Customer API mode, enabling client verification. */\n settings: Settings | null = null;\n\n private readonly __passwordGeneratorOptions: GeneratorOptions = {\n checkStrength: value => passwordStrength(value).id >= 2,\n };\n\n private readonly __isAnonymousGetValue = () => {\n return this.form?.is_anonymous === false ? 'false' : 'true';\n };\n\n private readonly __isAnonymousSetValue = (newValue: string) => {\n const isAnonymous = newValue === 'true';\n this.edit({ is_anonymous: isAnonymous });\n if (isAnonymous && this.form.password) this.edit({ password: '' });\n if (isAnonymous && this.form.password_old) this.edit({ password_old: '' });\n if (isAnonymous && this.form.forgot_password) this.edit({ forgot_password: '' });\n };\n\n private readonly __isAnonymousOptions = [\n { value: 'true', label: 'option_true' },\n { value: 'false', label: 'option_false' },\n ];\n\n private __refreshInterval: NodeJS.Timeout | null = null;\n\n get scopeCollection(): ScopeCollection | null {\n return 'customers';\n }\n\n get hiddenSelector(): BooleanSelector {\n const hidden = new Set<string>(super.hiddenSelector.toString().split(' '));\n\n if (this.settings) {\n hidden.add('forgot-password');\n hidden.add('is-anonymous');\n if (!this.form.password && !this.__isEmailChanged(this.form.email))\n hidden.add('password-old');\n if (this.settings.tos_checkbox_settings.usage === 'none') hidden.add('legal-notice');\n } else {\n if (this.form.is_anonymous !== false) {\n hidden.add('forgot-password');\n hidden.add('password');\n }\n hidden.add('password-old');\n hidden.add('legal-notice');\n }\n\n if (this.href) {\n hidden.add('is-anonymous');\n hidden.add('legal-notice');\n }\n\n return new BooleanSelector(Array.from(hidden).join(' ').trim());\n }\n\n get headerTitleOptions(): Record<string, unknown> {\n const data = this.data;\n if (!data || data.first_name?.trim() || data.last_name?.trim()) return super.headerTitleOptions;\n return { ...super.headerTitleOptions, context: 'no_name' };\n }\n\n get headerSubtitleKey(): string {\n return this.data?.is_anonymous ? 'subtitle_anonymous' : 'subtitle_registered';\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n return { ...super.headerSubtitleOptions, id: this.headerCopyIdValue };\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n const interval = this.__refreshInterval;\n if (interval) clearInterval(interval);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n const interval = setInterval(() => this.requestUpdate(), 60 * 1000);\n this.__refreshInterval = interval;\n }\n\n renderBody(): TemplateResult {\n const isFirstNameHidden = this.hiddenSelector.matches('first-name', true);\n const isLastNameHidden = this.hiddenSelector.matches('last-name', true);\n\n return html`\n ${this.renderHeader()}\n\n <div\n class=${classMap({\n 'grid-cols-2': !isFirstNameHidden && !isLastNameHidden,\n 'hidden': isFirstNameHidden && isLastNameHidden,\n 'gap-m': true,\n 'grid': !isFirstNameHidden || !isLastNameHidden,\n })}\n >\n <foxy-internal-text-control infer=\"first-name\"></foxy-internal-text-control>\n <foxy-internal-text-control infer=\"last-name\"></foxy-internal-text-control>\n </div>\n\n <foxy-internal-text-control helper-text=${this.__emailHelperText} infer=\"email\">\n </foxy-internal-text-control>\n\n <foxy-internal-radio-group-control\n infer=\"is-anonymous\"\n .getValue=${this.__isAnonymousGetValue}\n .setValue=${this.__isAnonymousSetValue}\n .options=${this.__isAnonymousOptions}\n >\n </foxy-internal-radio-group-control>\n\n <foxy-internal-password-control\n placeholder=${this.__passwordPlaceholder}\n helper-text=${this.__passwordHelperText}\n infer=\"password\"\n show-generator\n .generatorOptions=${this.__passwordGeneratorOptions}\n >\n </foxy-internal-password-control>\n\n <foxy-internal-password-control infer=\"password-old\"></foxy-internal-password-control>\n\n <foxy-internal-password-control\n helper-text=${this.__forgotPasswordHelperText}\n infer=\"forgot-password\"\n show-generator\n >\n </foxy-internal-password-control>\n\n <foxy-internal-text-control infer=\"tax-id\"></foxy-internal-text-control>\n\n <foxy-internal-customer-form-legal-notice-control infer=\"legal-notice\">\n </foxy-internal-customer-form-legal-notice-control>\n\n ${!this.data &&\n this.settings?.sign_up?.enabled &&\n this.settings?.sign_up?.verification.type === 'hcaptcha'\n ? html`\n <h-captcha\n site-key=${this.settings.sign_up.verification.site_key}\n class=\"hidden\"\n size=\"invisible\"\n hl=${this.lang}\n @verified=${({ token }: Record<'token' | 'eKey', string>) => {\n this.edit({ verification: { type: 'hcaptcha', token } });\n super.submit();\n }}\n >\n </h-captcha>\n `\n : ''}\n ${super.renderBody()}\n `;\n }\n\n submit(): void {\n if (this.settings?.sign_up?.verification?.type === 'hcaptcha' && !this.data) {\n this.__hcaptcha?.reset();\n this.__hcaptcha?.execute();\n } else {\n super.submit();\n }\n }\n\n protected async _sendPatch(edits: Partial<Data>): Promise<Data> {\n const data = await super._sendPatch(edits);\n\n if (edits.password) {\n const status = { key: 'password_change_success', options: { email: data.email } };\n this.status = status;\n }\n\n return data;\n }\n\n protected async _sendGet(): Promise<Data> {\n this.status = null;\n return await super._sendGet();\n }\n\n protected async _fetch<TResult = Data>(...args: Parameters<Window['fetch']>): Promise<TResult> {\n try {\n return await super._fetch(...args);\n } catch (err) {\n let message;\n\n try {\n message = (await (err as Response).json())._embedded['fx:errors'][0].message;\n } catch {\n throw err;\n }\n\n if (message === 'Conflict' || message.startsWith('This email address is already in use')) {\n throw ['error:email_already_used'];\n } else if (message.startsWith('Customer registration is disabled')) {\n throw ['error:registration_disabled'];\n } else if (message.startsWith('Client verification failed')) {\n throw ['error:verification_failed'];\n } else if (message.startsWith('Provided password is incorrect')) {\n throw ['error:old_password_incorrect'];\n } else if (message.startsWith('password_old is required')) {\n throw ['error:old_password_required'];\n } else {\n throw err;\n }\n }\n }\n\n private get __forgotPasswordHelperText() {\n const createdOn = this.data?.forgot_password_timestamp;\n const password = this.data?.forgot_password;\n const i18nKey = 'forgot-password.helper_text';\n\n if (password && createdOn) {\n const expiresOn = new Date(new Date(createdOn).getTime() + 30 * 60 * 1000);\n const expiresInMin = Math.floor((expiresOn.getTime() - Date.now()) / 1000 / 60);\n if (expiresInMin <= 0) return this.t(`${i18nKey}_expired_on`, { expiresOn });\n return this.t(`${i18nKey}_expires_in`, { expiresInMin: `${expiresInMin}minutes` });\n } else {\n return this.t(i18nKey);\n }\n }\n\n private get __passwordPlaceholder() {\n return this.data ? this.t('password.placeholder_new') : this.t('password.placeholder');\n }\n\n private get __passwordHelperText() {\n return this.data ? this.t('password.helper_text_new') : this.t('password.helper_text');\n }\n\n private get __emailHelperText() {\n return this.data?.last_login_date\n ? this.t('email.helper_text_last_login_date', { date: this.data.last_login_date })\n : this.t('email.helper_text');\n }\n\n private get __hcaptcha() {\n return this.renderRoot.querySelector<VanillaHCaptchaWebComponent>('h-captcha');\n }\n\n /** True when `email` differs from the saved one. Customer API asks for the current password to change it. */\n private __isEmailChanged(email: string | undefined): boolean {\n const saved = this.data?.email;\n if (!saved || email === undefined) return false;\n return email.trim().toLowerCase() !== saved.trim().toLowerCase();\n }\n}\n"]}
|
|
@@ -90,10 +90,13 @@ export class PaymentCard extends Base {
|
|
|
90
90
|
<foxy-i18n .options=${{ value: data === null || data === void 0 ? void 0 : data.date_created }} infer="" key="date"></foxy-i18n>
|
|
91
91
|
</span>
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
${this.__gatewayName
|
|
94
|
+
? html `
|
|
95
|
+
<span class="block text-s text-secondary" data-testid="gateway">
|
|
96
|
+
${this.__gatewayName}
|
|
97
|
+
</span>
|
|
98
|
+
`
|
|
99
|
+
: ''}
|
|
97
100
|
${infoKeys.map(key => {
|
|
98
101
|
if (!(data === null || data === void 0 ? void 0 : data[key]))
|
|
99
102
|
return;
|
|
@@ -132,7 +135,15 @@ export class PaymentCard extends Base {
|
|
|
132
135
|
return false;
|
|
133
136
|
if (!this.__currencyDisplay)
|
|
134
137
|
return false;
|
|
135
|
-
|
|
138
|
+
if (this.__gatewayName)
|
|
139
|
+
return true;
|
|
140
|
+
// Wait for both helpers to settle (loaded or failed) instead of waiting for a match:
|
|
141
|
+
// gateway_type can be empty or missing from the helpers, and then it would never match.
|
|
142
|
+
const isSettled = (helper, loader) => {
|
|
143
|
+
return !helper || !!(loader === null || loader === void 0 ? void 0 : loader.data) || !!(loader === null || loader === void 0 ? void 0 : loader.in('fail'));
|
|
144
|
+
};
|
|
145
|
+
return (isSettled(this.hostedPaymentGatewaysHelper, this.__hostedPaymentGatewaysLoader) &&
|
|
146
|
+
isSettled(this.paymentGatewaysHelper, this.__paymentGatewaysLoader));
|
|
136
147
|
}
|
|
137
148
|
get __hostedPaymentGatewaysLoader() {
|
|
138
149
|
return this.renderRoot.querySelector(`#${this.__hostedPaymentGatewaysLoaderId}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentCard.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentCard/PaymentCard.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,sCAAmC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,qCAAkC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,cAAc,CAAC;AAC1B,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,OAAO,WAAY,SAAQ,IAAU;IAA3C;;QASE,wEAAwE;QACxE,gCAA2B,GAAkB,IAAI,CAAC;QAElD,iEAAiE;QACjE,0BAAqB,GAAkB,IAAI,CAAC;QAE3B,oCAA+B,GAAG,6BAA6B,CAAC;QAEhE,8BAAyB,GAAG,uBAAuB,CAAC;QAEpD,0BAAqB,GAAG,mBAAmB,CAAC;QAE5C,oBAAe,GAAG,aAAa,CAAC;IAqJnD,CAAC;IAzKC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,2BAA2B,EAAE,EAAE,SAAS,EAAE,gCAAgC,EAAE;YAC5E,qBAAqB,EAAE,EAAE,SAAS,EAAE,yBAAyB,EAAE;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,CAAC,iCAAiC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACxF,CAAC;IAED,IAAY,cAAc;;QACxB,mBAAO,IAAI,CAAC,mBAAmB,0CAAE,IAAI,0CAAE,aAAa,CAAC;IACvD,CAAC;IAED,IAAY,aAAa;;QACvB,MAAM,IAAI,SAAG,IAAI,CAAC,IAAI,0CAAE,YAAY,CAAC;QACrC,IAAI,IAAI,EAAE;YACR,MAAM,OAAO,eAAG,IAAI,CAAC,uBAAuB,0CAAE,IAAI,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YACjE,MAAM,aAAa,eAAG,IAAI,CAAC,6BAA6B,0CAAE,IAAI,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7E,aAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CAAC;SAC7C;IACH,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport * as logos from '../PaymentMethodCard/logos';\n\nimport { canReadCollection } from '../../../utils/user-scope';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'payment-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying a payment resource (`fx:payment`).\n *\n * @element foxy-payment-card\n * @since 1.11.0\n */\nexport class PaymentCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n hostedPaymentGatewaysHelper: { attribute: 'hosted-payment-gateways-helper' },\n paymentGatewaysHelper: { attribute: 'payment-gateways-helper' },\n };\n }\n\n /** URL of the `fx:hosted_payment_gateways` property helper resource. */\n hostedPaymentGatewaysHelper: string | null = null;\n\n /** URL of the `fx:payment_gateways` property helper resource. */\n paymentGatewaysHelper: string | null = null;\n\n private readonly __hostedPaymentGatewaysLoaderId = 'hostedPaymentGatewaysLoader';\n\n private readonly __paymentGatewaysLoaderId = 'paymentGatewaysLoader';\n\n private readonly __transactionLoaderId = 'transactionLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n renderBody(): TemplateResult {\n const data = this.data;\n const amount = `${data?.amount ?? ''} ${this.__currencyCode}`;\n const amountOptions = { currencyDisplay: this.__currencyDisplay, amount };\n\n const infoKeys = [\n 'processor_response',\n 'paypal_payer_id',\n 'third_party_id',\n 'purchase_order',\n ] as const;\n\n const score = this.data?.fraud_protection_score ?? 0;\n const scoreColor = score > 0 ? 'text-error' : 'text-success';\n const scoreBackground = score > 0 ? 'bg-error-10' : 'bg-success-10';\n\n const type = (data?.cc_type ?? 'unknown').toLowerCase() as keyof typeof logos;\n const year = data?.cc_exp_year?.substring(2);\n const month = data?.cc_exp_month;\n const last4Digits = data?.cc_number_masked?.replace(/x/gi, '');\n\n return html`\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.hostedPaymentGatewaysHelper ?? undefined)}\n id=${this.__hostedPaymentGatewaysLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.paymentGatewaysHelper ?? undefined)}\n id=${this.__paymentGatewaysLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(data?._links['fx:transaction'].href)}\n id=${this.__transactionLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.__canReadStore ? data?._links['fx:store'].href : undefined)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <p class=\"leading-s\">\n <span class=\"block font-medium text-m\" data-testid=\"line-1\">\n <foxy-i18n .options=${amountOptions} infer=\"\" key=\"price\"></foxy-i18n>\n <span> • </span>\n <foxy-i18n .options=${{ value: data?.date_created }} infer=\"\" key=\"date\"></foxy-i18n>\n </span>\n\n <span class=\"block text-s text-secondary\">\n ${this.__gatewayName || html`<foxy-i18n infer=\"\" key=\"unknown\"></foxy-i18n>`}\n </span>\n\n ${infoKeys.map(key => {\n if (!data?.[key]) return;\n const css = 'block text-s text-tertiary';\n return html`<foxy-i18n class=${css} infer=\"\" key=${key} .options=${data}></foxy-i18n>`;\n })}\n\n <span class=\"mt-s flex space-x-s overflow-auto\">\n ${month && year && last4Digits\n ? html`\n <span\n class=\"truncate flex items-center h-xs rounded-s overflow-hidden bg-contrast-5\"\n data-testid=\"card-info\"\n >\n <span class=\"h-xs\">${logos[type] ?? logos.unknown}</span>\n <span class=\"font-medium px-s\">•••• ${last4Digits} ${month}/${year}</span>\n </span>\n `\n : ''}\n\n <foxy-i18n\n class=\"truncate flex font-medium h-xs items-center px-s rounded-s text-s ${scoreColor} ${scoreBackground}\"\n infer=\"\"\n key=\"fraud_risk\"\n .options=${{ score }}\n >\n </foxy-i18n>\n </span>\n </p>\n `;\n }\n\n get isBodyReady(): boolean {\n if (!super.isBodyReady) return false;\n if (!this.__currencyCode) return false;\n if (!this.__currencyDisplay) return false;\n return !this.hostedPaymentGatewaysHelper || !this.paymentGatewaysHelper || !!this.__gatewayName;\n }\n\n private get __hostedPaymentGatewaysLoader() {\n type Loader = NucleonElement<Resource<Rels.HostedPaymentGatewaysHelper>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__hostedPaymentGatewaysLoaderId}`);\n }\n\n private get __paymentGatewaysLoader() {\n type Loader = NucleonElement<Resource<Rels.PaymentGatewaysHelper>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__paymentGatewaysLoaderId}`);\n }\n\n private get __transactionLoader() {\n type Loader = NucleonElement<Resource<Rels.Transaction>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__transactionLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n // Payments belong to transactions, so the transaction is always readable here.\n // Without the store the price falls back to the currency symbol.\n private get __canReadStore() {\n return canReadCollection(this.currentUserScope, 'stores');\n }\n\n private get __currencyDisplay() {\n const store = this.__storeLoader?.data;\n if (!store && !this.__canReadStore) return 'symbol';\n return store ? (store.use_international_currency_symbol ? 'code' : 'symbol') : void 0;\n }\n\n private get __currencyCode() {\n return this.__transactionLoader?.data?.currency_code;\n }\n\n private get __gatewayName() {\n const type = this.data?.gateway_type;\n if (type) {\n const gateway = this.__paymentGatewaysLoader?.data?.values[type];\n const hostedGateway = this.__hostedPaymentGatewaysLoader?.data?.values[type];\n return gateway?.name ?? hostedGateway?.name;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PaymentCard.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentCard/PaymentCard.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,sCAAmC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,qCAAkC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,cAAc,CAAC;AAC1B,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE;;;;;GAKG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AI,EAAE;YACR,MAAM,OAAO,eAAG,IAAI,CAAC,uBAAuB,0CAAE,IAAI,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YACjE,MAAM,aAAa,eAAG,IAAI,CAAC,6BAA6B,0CAAE,IAAI,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7E,aAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CAAC;SAC7C;IACH,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport * as logos from '../PaymentMethodCard/logos';\n\nimport { canReadCollection } from '../../../utils/user-scope';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'payment-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying a payment resource (`fx:payment`).\n *\n * @element foxy-payment-card\n * @since 1.11.0\n */\nexport class PaymentCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n hostedPaymentGatewaysHelper: { attribute: 'hosted-payment-gateways-helper' },\n paymentGatewaysHelper: { attribute: 'payment-gateways-helper' },\n };\n }\n\n /** URL of the `fx:hosted_payment_gateways` property helper resource. */\n hostedPaymentGatewaysHelper: string | null = null;\n\n /** URL of the `fx:payment_gateways` property helper resource. */\n paymentGatewaysHelper: string | null = null;\n\n private readonly __hostedPaymentGatewaysLoaderId = 'hostedPaymentGatewaysLoader';\n\n private readonly __paymentGatewaysLoaderId = 'paymentGatewaysLoader';\n\n private readonly __transactionLoaderId = 'transactionLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n renderBody(): TemplateResult {\n const data = this.data;\n const amount = `${data?.amount ?? ''} ${this.__currencyCode}`;\n const amountOptions = { currencyDisplay: this.__currencyDisplay, amount };\n\n const infoKeys = [\n 'processor_response',\n 'paypal_payer_id',\n 'third_party_id',\n 'purchase_order',\n ] as const;\n\n const score = this.data?.fraud_protection_score ?? 0;\n const scoreColor = score > 0 ? 'text-error' : 'text-success';\n const scoreBackground = score > 0 ? 'bg-error-10' : 'bg-success-10';\n\n const type = (data?.cc_type ?? 'unknown').toLowerCase() as keyof typeof logos;\n const year = data?.cc_exp_year?.substring(2);\n const month = data?.cc_exp_month;\n const last4Digits = data?.cc_number_masked?.replace(/x/gi, '');\n\n return html`\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.hostedPaymentGatewaysHelper ?? undefined)}\n id=${this.__hostedPaymentGatewaysLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.paymentGatewaysHelper ?? undefined)}\n id=${this.__paymentGatewaysLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(data?._links['fx:transaction'].href)}\n id=${this.__transactionLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.__canReadStore ? data?._links['fx:store'].href : undefined)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <p class=\"leading-s\">\n <span class=\"block font-medium text-m\" data-testid=\"line-1\">\n <foxy-i18n .options=${amountOptions} infer=\"\" key=\"price\"></foxy-i18n>\n <span> • </span>\n <foxy-i18n .options=${{ value: data?.date_created }} infer=\"\" key=\"date\"></foxy-i18n>\n </span>\n\n ${this.__gatewayName\n ? html`\n <span class=\"block text-s text-secondary\" data-testid=\"gateway\">\n ${this.__gatewayName}\n </span>\n `\n : ''}\n ${infoKeys.map(key => {\n if (!data?.[key]) return;\n const css = 'block text-s text-tertiary';\n return html`<foxy-i18n class=${css} infer=\"\" key=${key} .options=${data}></foxy-i18n>`;\n })}\n\n <span class=\"mt-s flex space-x-s overflow-auto\">\n ${month && year && last4Digits\n ? html`\n <span\n class=\"truncate flex items-center h-xs rounded-s overflow-hidden bg-contrast-5\"\n data-testid=\"card-info\"\n >\n <span class=\"h-xs\">${logos[type] ?? logos.unknown}</span>\n <span class=\"font-medium px-s\">•••• ${last4Digits} ${month}/${year}</span>\n </span>\n `\n : ''}\n\n <foxy-i18n\n class=\"truncate flex font-medium h-xs items-center px-s rounded-s text-s ${scoreColor} ${scoreBackground}\"\n infer=\"\"\n key=\"fraud_risk\"\n .options=${{ score }}\n >\n </foxy-i18n>\n </span>\n </p>\n `;\n }\n\n get isBodyReady(): boolean {\n if (!super.isBodyReady) return false;\n if (!this.__currencyCode) return false;\n if (!this.__currencyDisplay) return false;\n if (this.__gatewayName) return true;\n\n // Wait for both helpers to settle (loaded or failed) instead of waiting for a match:\n // gateway_type can be empty or missing from the helpers, and then it would never match.\n const isSettled = (helper: string | null, loader: NucleonElement<any> | null) => {\n return !helper || !!loader?.data || !!loader?.in('fail');\n };\n\n return (\n isSettled(this.hostedPaymentGatewaysHelper, this.__hostedPaymentGatewaysLoader) &&\n isSettled(this.paymentGatewaysHelper, this.__paymentGatewaysLoader)\n );\n }\n\n private get __hostedPaymentGatewaysLoader() {\n type Loader = NucleonElement<Resource<Rels.HostedPaymentGatewaysHelper>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__hostedPaymentGatewaysLoaderId}`);\n }\n\n private get __paymentGatewaysLoader() {\n type Loader = NucleonElement<Resource<Rels.PaymentGatewaysHelper>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__paymentGatewaysLoaderId}`);\n }\n\n private get __transactionLoader() {\n type Loader = NucleonElement<Resource<Rels.Transaction>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__transactionLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n // Payments belong to transactions, so the transaction is always readable here.\n // Without the store the price falls back to the currency symbol.\n private get __canReadStore() {\n return canReadCollection(this.currentUserScope, 'stores');\n }\n\n private get __currencyDisplay() {\n const store = this.__storeLoader?.data;\n if (!store && !this.__canReadStore) return 'symbol';\n return store ? (store.use_international_currency_symbol ? 'code' : 'symbol') : void 0;\n }\n\n private get __currencyCode() {\n return this.__transactionLoader?.data?.currency_code;\n }\n\n private get __gatewayName() {\n const type = this.data?.gateway_type;\n if (type) {\n const gateway = this.__paymentGatewaysLoader?.data?.values[type];\n const hostedGateway = this.__hostedPaymentGatewaysLoader?.data?.values[type];\n return gateway?.name ?? hostedGateway?.name;\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./shared-a6b2bd14.js";import"./shared-af4f71bf.js";import"./shared-32a39c0b.js";import"./shared-091e97f3.js";import{I as e}from"./shared-9b290320.js";import{a as t}from"./shared-4ab85bea.js";import"./shared-c066b7fd.js";import{i as s}from"./shared-53e42a77.js";import{h as o}from"./shared-ba5c42c7.js";import{c as r,_ as n,B as i}from"./shared-8f9014ff.js";import{S as a,a as l}from"./shared-5b8c7250.js";import{v as d}from"./shared-b738ee96.js";import{c}from"./shared-4e709717.js";let h,p=e=>e;customElements.define("foxy-internal-customer-form-legal-notice-control",class extends t{renderControl(){var e,t;const r=this.nucleon;return o(h||(h=p` <p class="leading-s text-xs text-secondary"> <foxy-i18n infer="" key="text"></foxy-i18n> <a class="font-medium text-body rounded hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50" target="_blank" href="${0}" rel="noopener noreferrer"> <foxy-i18n infer="" key="link"></foxy-i18n> </a> </p> `),s(null===(t=null===(e=null==r?void 0:r.settings)||void 0===e?void 0:e.tos_checkbox_settings)||void 0===t?void 0:t.url))}});var u=r((function(e){!function(){const t=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],s=(e,s=t,o="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=e||"";s[0].minDiversity=0,s[0].minLength=0;const n=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];o&&n.push({regex:`[${o}]`,message:"symbol"});let i={};i.contains=n.filter((e=>new RegExp(`${e.regex}`).test(r))).map((e=>e.message)),i.length=r.length;let a=s.filter((e=>i.contains.length>=e.minDiversity)).filter((e=>i.length>=e.minLength)).sort(((e,t)=>t.id-e.id)).map((e=>({id:e.id,value:e.value})));return Object.assign(i,a[0]),i};e.exports={passwordStrength:s,defaultOptions:t}}()}));let m,f,_=e=>e;const g=a(l(e,"customer-form")),x=u.passwordStrength;class v extends g{constructor(){super(...arguments),this.passwordless=!1,this.settings=null,this.__passwordGeneratorOptions={checkStrength:e=>x(e).id>=2},this.__isAnonymousGetValue=()=>{var e;return!1===(null===(e=this.form)||void 0===e?void 0:e.is_anonymous)?"false":"true"},this.__isAnonymousSetValue=e=>{const t="true"===e;this.edit({is_anonymous:t}),t&&this.form.password&&this.edit({password:""}),t&&this.form.password_old&&this.edit({password_old:""}),t&&this.form.forgot_password&&this.edit({forgot_password:""})},this.__isAnonymousOptions=[{value:"true",label:"option_true"},{value:"false",label:"option_false"}],this.__refreshInterval=null}static get scopedElements(){return{"foxy-internal-customer-form-legal-notice-control":customElements.get("foxy-internal-customer-form-legal-notice-control"),"foxy-internal-radio-group-control":customElements.get("foxy-internal-radio-group-control"),"foxy-internal-timestamps-control":customElements.get("foxy-internal-timestamps-control"),"foxy-internal-password-control":customElements.get("foxy-internal-password-control"),"foxy-internal-submit-control":customElements.get("foxy-internal-submit-control"),"foxy-internal-delete-control":customElements.get("foxy-internal-delete-control"),"foxy-internal-text-control":customElements.get("foxy-internal-text-control"),"foxy-internal-undo-control":customElements.get("foxy-internal-undo-control"),"foxy-copy-to-clipboard":customElements.get("foxy-copy-to-clipboard"),"foxy-spinner":customElements.get("foxy-spinner"),"vcf-tooltip":customElements.get("vcf-tooltip"),"foxy-i18n":customElements.get("foxy-i18n"),"h-captcha":customElements.get("h-captcha"),"vaadin-button":customElements.get("vaadin-button")}}static get properties(){return n(n({},super.properties),{},{passwordless:{type:Boolean},settings:{type:Object}})}static get v8n(){return[({password:e,_links:t,is_anonymous:s=!0},o)=>!!o.passwordless||(!!(t||s||e)||"password:v8n_required"),({password_old:e,password:t,_links:s},o)=>{var r;return!s||(void 0===(null===(r=o.settings)||void 0===r?void 0:r.sign_up)||(!(t&&!e)||"password-old:v8n_required"))},({first_name:e})=>!e||e.length<=50||"first-name:v8n_too_long",({last_name:e})=>!e||e.length<=50||"last-name:v8n_too_long",({password:e})=>!e||x(e).id>=2||"password:v8n_too_weak",({password:e})=>!e||e.length<=50||"password:v8n_too_long",({tax_id:e})=>!e||e.length<=50||"tax-id:v8n_too_long",({email:e})=>e&&e.length>0||"email:v8n_required",({email:e})=>!e||e.length<=100||"email:v8n_too_long",({email:e})=>!e||d(e)||"email:v8n_invalid_email"]}get scopeCollection(){return"customers"}get hiddenSelector(){const e=new Set(super.hiddenSelector.toString().split(" "));return this.settings?(e.add("forgot-password"),e.add("is-anonymous"),this.form.password||e.add("password-old"),"none"===this.settings.tos_checkbox_settings.usage&&e.add("legal-notice")):(!1!==this.form.is_anonymous&&(e.add("forgot-password"),e.add("password")),e.add("password-old"),e.add("legal-notice")),this.href&&(e.add("is-anonymous"),e.add("legal-notice")),new i(Array.from(e).join(" ").trim())}get headerTitleOptions(){var e,t;const s=this.data;return!s||(null===(e=s.first_name)||void 0===e?void 0:e.trim())||(null===(t=s.last_name)||void 0===t?void 0:t.trim())?super.headerTitleOptions:n(n({},super.headerTitleOptions),{},{context:"no_name"})}get headerSubtitleKey(){var e;return(null===(e=this.data)||void 0===e?void 0:e.is_anonymous)?"subtitle_anonymous":"subtitle_registered"}get headerSubtitleOptions(){return n(n({},super.headerSubtitleOptions),{},{id:this.headerCopyIdValue})}disconnectedCallback(){super.disconnectedCallback();const e=this.__refreshInterval;e&&clearInterval(e)}connectedCallback(){super.connectedCallback();const e=setInterval((()=>this.requestUpdate()),6e4);this.__refreshInterval=e}renderBody(){var e,t,s,r;const n=this.hiddenSelector.matches("first-name",!0),i=this.hiddenSelector.matches("last-name",!0);return o(m||(m=_` ${0} <div class="${0}"> <foxy-internal-text-control infer="first-name"></foxy-internal-text-control> <foxy-internal-text-control infer="last-name"></foxy-internal-text-control> </div> <foxy-internal-text-control helper-text="${0}" infer="email"> </foxy-internal-text-control> <foxy-internal-radio-group-control infer="is-anonymous" .getValue="${0}" .setValue="${0}" .options="${0}"> </foxy-internal-radio-group-control> <foxy-internal-password-control placeholder="${0}" helper-text="${0}" infer="password" show-generator .generatorOptions="${0}"> </foxy-internal-password-control> <foxy-internal-password-control infer="password-old"></foxy-internal-password-control> <foxy-internal-password-control helper-text="${0}" infer="forgot-password" show-generator> </foxy-internal-password-control> <foxy-internal-text-control infer="tax-id"></foxy-internal-text-control> <foxy-internal-customer-form-legal-notice-control infer="legal-notice"> </foxy-internal-customer-form-legal-notice-control> ${0} ${0} `),this.renderHeader(),c({"grid-cols-2":!n&&!i,hidden:n&&i,"gap-m":!0,grid:!n||!i}),this.__emailHelperText,this.__isAnonymousGetValue,this.__isAnonymousSetValue,this.__isAnonymousOptions,this.__passwordPlaceholder,this.__passwordHelperText,this.__passwordGeneratorOptions,this.__forgotPasswordHelperText,!this.data&&(null===(t=null===(e=this.settings)||void 0===e?void 0:e.sign_up)||void 0===t?void 0:t.enabled)&&"hcaptcha"===(null===(r=null===(s=this.settings)||void 0===s?void 0:s.sign_up)||void 0===r?void 0:r.verification.type)?o(f||(f=_` <h-captcha site-key="${0}" class="hidden" size="invisible" hl="${0}" @verified="${0}"> </h-captcha> `),this.settings.sign_up.verification.site_key,this.lang,(({token:e})=>{this.edit({verification:{type:"hcaptcha",token:e}}),super.submit()})):"",super.renderBody())}submit(){var e,t,s,o,r;"hcaptcha"!==(null===(s=null===(t=null===(e=this.settings)||void 0===e?void 0:e.sign_up)||void 0===t?void 0:t.verification)||void 0===s?void 0:s.type)||this.data?super.submit():(null===(o=this.__hcaptcha)||void 0===o||o.reset(),null===(r=this.__hcaptcha)||void 0===r||r.execute())}async _sendPatch(e){const t=await super._sendPatch(e);if(e.password){const e={key:"password_change_success",options:{email:t.email}};this.status=e}return t}async _sendGet(){return this.status=null,await super._sendGet()}async _fetch(...e){try{return await super._fetch(...e)}catch(e){let t;try{t=(await e.json())._embedded["fx:errors"][0].message}catch(t){throw e}throw"Conflict"===t||t.startsWith("This email address is already in use")?["error:email_already_used"]:t.startsWith("Customer registration is disabled")?["error:registration_disabled"]:t.startsWith("Client verification failed")?["error:verification_failed"]:t.startsWith("Provided password is incorrect")?["error:old_password_incorrect"]:e}}get __forgotPasswordHelperText(){var e,t;const s=null===(e=this.data)||void 0===e?void 0:e.forgot_password_timestamp,o="forgot-password.helper_text";if((null===(t=this.data)||void 0===t?void 0:t.forgot_password)&&s){const e=new Date(new Date(s).getTime()+18e5),t=Math.floor((e.getTime()-Date.now())/1e3/60);return t<=0?this.t(`${o}_expired_on`,{expiresOn:e}):this.t(`${o}_expires_in`,{expiresInMin:`${t}minutes`})}return this.t(o)}get __passwordPlaceholder(){return this.data?this.t("password.placeholder_new"):this.t("password.placeholder")}get __passwordHelperText(){return this.data?this.t("password.helper_text_new"):this.t("password.helper_text")}get __emailHelperText(){var e;return(null===(e=this.data)||void 0===e?void 0:e.last_login_date)?this.t("email.helper_text_last_login_date",{date:this.data.last_login_date}):this.t("email.helper_text")}get __hcaptcha(){return this.renderRoot.querySelector("h-captcha")}}customElements.define("foxy-customer-form",v);export{v as C,u};
|