@foxy.io/elements 1.60.1 → 1.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/shared-8062bbb8.js +1 -0
- 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/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/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.
|
|
@@ -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};
|
|
@@ -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": {
|
|
@@ -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,EA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":["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,EA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AAC,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;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"]}
|
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};
|