@foxy.io/elements 1.59.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-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-card.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-admin-transaction-card.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-billing-address-card.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-card.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-client-card.js +1 -1
- package/dist/cdn/foxy-client-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-detail-card.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-api.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-builder.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-discount-detail-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-downloadable-card.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-card.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
- package/dist/cdn/foxy-filter-attribute-card.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-i18n-editor.js +1 -1
- package/dist/cdn/foxy-integration-card.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-card.js +1 -1
- package/dist/cdn/foxy-item-category-card.js +1 -1
- package/dist/cdn/foxy-item-category-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-card.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-native-integration-card.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-nucleon-element.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -1
- package/dist/cdn/foxy-passkey-card.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-card-embed.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-query-builder.js +1 -1
- package/dist/cdn/foxy-report-form.js +1 -1
- package/dist/cdn/foxy-reports-table.js +6 -6
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-shipping-container-card.js +1 -1
- package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
- package/dist/cdn/foxy-shipping-method-card.js +1 -1
- package/dist/cdn/foxy-shipping-service-card.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-store-card.js +1 -1
- package/dist/cdn/foxy-store-form.js +1 -1
- package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
- package/dist/cdn/foxy-store-transaction-folder-card.js +1 -1
- package/dist/cdn/foxy-store-transaction-folder-form.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscription-settings-form.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-card.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +1 -1
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-card.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-card.js +1 -1
- package/dist/cdn/foxy-user-invitation-form.js +1 -1
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-card.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/foxy-webhook-log-card.js +1 -1
- package/dist/cdn/foxy-webhook-status-card.js +1 -1
- package/dist/cdn/{shared-7b6a899b.js → shared-091e97f3.js} +1 -1
- package/dist/cdn/shared-0996f4d0.js +1 -0
- package/dist/cdn/{shared-3991076b.js → shared-0b0ab3d2.js} +1 -1
- package/dist/cdn/{shared-14713ead.js → shared-18707481.js} +1 -1
- package/dist/cdn/{shared-336e73ce.js → shared-222b23bb.js} +1 -1
- package/dist/cdn/shared-2fbff8e7.js +1 -0
- package/dist/cdn/{shared-8ec1b077.js → shared-32a39c0b.js} +1 -1
- package/dist/cdn/shared-345b07f1.js +1 -0
- package/dist/cdn/{shared-bc74cd11.js → shared-3a61d8a6.js} +1 -1
- package/dist/cdn/{shared-1e9df11c.js → shared-3ef23488.js} +1 -1
- package/dist/cdn/{shared-33d770fe.js → shared-40a2705c.js} +1 -1
- package/dist/cdn/{shared-cb5305b9.js → shared-41f93e6c.js} +1 -1
- package/dist/cdn/{shared-45649d84.js → shared-4ab85bea.js} +1 -1
- package/dist/cdn/{shared-28fa98d7.js → shared-4ed4b075.js} +1 -1
- package/dist/cdn/{shared-20841d9c.js → shared-56278a3c.js} +1 -1
- package/dist/cdn/{shared-d743ec15.js → shared-5e7defee.js} +1 -1
- package/dist/cdn/{shared-59dfee2c.js → shared-7b15217c.js} +1 -1
- package/dist/cdn/{shared-1a814f90.js → shared-7e28c953.js} +1 -1
- package/dist/cdn/shared-8062bbb8.js +1 -0
- package/dist/cdn/{shared-2652e98e.js → shared-8292d44e.js} +1 -1
- package/dist/cdn/shared-87e17c02.js +1 -0
- package/dist/cdn/{shared-a1bec4a0.js → shared-88f841ff.js} +1 -1
- package/dist/cdn/{shared-3eca56ee.js → shared-8be109a9.js} +1 -1
- package/dist/cdn/{shared-9f8b593b.js → shared-8f5c8c08.js} +1 -1
- package/dist/cdn/{shared-be20875c.js → shared-9b290320.js} +1 -1
- package/dist/cdn/{shared-b84996e5.js → shared-a95a66b8.js} +1 -1
- package/dist/cdn/{shared-4cc16cdf.js → shared-ac536c67.js} +1 -1
- package/dist/cdn/{shared-38e0a818.js → shared-af4f71bf.js} +1 -1
- package/dist/cdn/{shared-50ef1d5a.js → shared-c85c1864.js} +1 -1
- package/dist/cdn/{shared-760a2243.js → shared-cda51ccf.js} +1 -1
- package/dist/cdn/{shared-db17c9ee.js → shared-d2f777dc.js} +1 -1
- package/dist/cdn/{shared-fdf6df5c.js → shared-e9f9face.js} +1 -1
- package/dist/cdn/{shared-3baa9cc9.js → shared-eb349085.js} +1 -1
- package/dist/cdn/{shared-19b475f7.js → shared-f9c8881a.js} +1 -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/user-invitation-form/en.json +4 -0
- 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/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.d.ts +5 -2
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.js +28 -8
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.js.map +1 -1
- package/dist/utils/group-invitation-scopes.d.ts +1 -1
- package/dist/utils/group-invitation-scopes.js +4 -2
- package/dist/utils/group-invitation-scopes.js.map +1 -1
- package/dist/utils/invitation-scope.d.ts +1 -1
- package/dist/utils/invitation-scope.js +9 -10
- package/dist/utils/invitation-scope.js.map +1 -1
- package/dist/utils/user-scope.js +2 -2
- package/dist/utils/user-scope.js.map +1 -1
- package/package.json +1 -1
- package/dist/cdn/shared-36f1e29f.js +0 -1
- package/dist/cdn/shared-559b648a.js +0 -1
- package/dist/cdn/shared-a44fcc6a.js +0 -1
- package/dist/cdn/shared-ab1f5f1f.js +0 -1
- package/dist/cdn/shared-da3393a5.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-a8ae24f0.js";import"./shared-
|
|
1
|
+
import"./shared-a8ae24f0.js";import"./shared-3a61d8a6.js";import{I as e}from"./shared-4ab85bea.js";import{I as t}from"./shared-9b290320.js";import"./foxy-copy-to-clipboard.js";import"./foxy-nucleon-element.js";import"./foxy-form-dialog.js";import"./shared-c066b7fd.js";import{_ as s,m as i,F as r}from"./shared-8f9014ff.js";import{h as o,s as l}from"./shared-ba5c42c7.js";import{s as a}from"./shared-53e476fd.js";import{g as n}from"./shared-bab2ea2c.js";import{i as d}from"./shared-53e42a77.js";import{c as h}from"./shared-4e709717.js";import{u}from"./shared-c85c1864.js";let c,f=e=>e;let p,y,m,v,x,b,_,g,$=e=>e;customElements.define("foxy-internal-resource-picker-control-form",class extends t{constructor(){super(...arguments),this.selectionProps={}}static get properties(){return s(s({},super.properties),{},{selectionProps:{attribute:!1}})}renderBody(){return o(c||(c=f` <foxy-internal-async-list-control infer="selection" form="foxy-null" hide-delete-button hide-create-button @itemclick="${0}" ...="${0}"> </foxy-internal-async-list-control> `),(e=>{e.preventDefault(),this.edit({selection:e.detail}),this.submit()}),a(this.selectionProps))}}),customElements.define("foxy-internal-resource-picker-control",class extends e{constructor(){super(...arguments),this.getDisplayValueOptions=e=>({resource:e}),this.showCopyIdButton=!1,this.virtualHost=u("internal-resource-picker-control-"),this.getItemUrl=null,this.formProps={},this.filters=[],this.extendFilter=null,this.layout=null,this.first=null,this.item=null,this.form=null,this.__isErrorVisible=!1,this.__getItemRenderer=i((e=>new Function("ctx",`return ctx.html\`\n <${null!=e?e:"foxy-null"}\n related=\${JSON.stringify(ctx.related)}\n parent=\${ctx.parent}\n infer="card"\n href=\${ctx.href}\n ...=\${ctx.spread(ctx.props)}\n >\n </${null!=e?e:"foxy-null"}>\``)))}static get properties(){return s(s({},super.properties),{},{getDisplayValueOptions:{attribute:!1},showCopyIdButton:{type:Boolean,attribute:"show-copy-id-button"},virtualHost:{},getItemUrl:{attribute:!1},formProps:{type:Object},filters:{type:Array},extendFilter:{type:Function,attribute:!1},layout:{},first:{},item:{},form:{},__isErrorVisible:{attribute:!1}})}renderControl(){var e;const t=s(s({},this.formProps),{},{".selectionProps":{".extendFilter":this.extendFilter,".filters":this.filters,".first":this.first,".item":this.item}});return o(p||(p=$` <foxy-form-dialog parent="foxy://${0}/select" header="header" infer="dialog" alert .props="${0}" .form="${0}" @fetch="${0}" @hide="${0}"> </foxy-form-dialog> ${0} `),this.virtualHost,t,null!==(e=this.form)&&void 0!==e?e:"foxy-internal-resource-picker-control-form",this.__handleFetchEvent,(()=>this.__isErrorVisible=!0),"summary-item"===this.layout?this.__renderSummaryItemLayout():this.__renderStandaloneLayout())}reportValidity(){this.__isErrorVisible=!0,super.reportValidity()}updated(e){var t,s;super.updated(e),e.has("item")&&(null===(s=(t=this.__getItemRenderer.cache).clear)||void 0===s||s.call(t))}_handleHostClick(e){var t;if("summary-item"!==this.layout)return;const s=e.composedPath(),i=new Set(["BUTTON"]);s.some((e=>i.has(e.tagName)))||(null===(t=this.renderRoot.querySelector("button"))||void 0===t||t.click(),super._handleHostClick(e))}__clear(){this._value="",this.dispatchEvent(new CustomEvent("clear"))}__renderSummaryItemLayout(){const e=this.renderRoot.querySelector("#value");return o(y||(y=$` <div class="leading-xs"> <div class="flex items-center gap-xs"> <div class="text-m text-body whitespace-nowrap flex-1">${0}</div> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <div class="truncate min-w-0"> ${0} </div> </button> <button aria-label="${0}" class="${0}" style="width:1em;height:1em" ?disabled="${0}" ?hidden="${0}" @click="${0}"> ${0} </button> </div> <div style="max-width:32rem"> <div class="text-xs text-secondary">${0}</div> <div class="text-xs text-error" ?hidden="${0}"> ${0} </div> </div> </div> <foxy-nucleon infer="" href="${0}" id="value" @update="${0}"> </foxy-nucleon> `),this.label,this.t("select"),h({"text-right min-w-0 transition-colors transition-opacity":!0,"rounded-s focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"text-secondary":this.readonly,"text-disabled":this.disabled,"cursor-pointer text-body hover-opacity-80":!this.disabled&&!this.readonly,"font-medium":!this.readonly}),this.disabled||this.readonly,(e=>{if(this.disabled||this.readonly)return;const t=e.currentTarget,s=this.renderRoot.querySelector("foxy-form-dialog");s.href="",s.show(t)}),this._value?o(m||(m=$` <foxy-i18n infer="" key="value" .options="${0}"> </foxy-i18n> `),(null==e?void 0:e.data)?this.getDisplayValueOptions(e.data):{context:(null==e?void 0:e.in("fail"))?"fail":"busy"}):this.placeholder,this.t("clear"),h({"rounded-full transition-colors":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"cursor-pointer text-tertiary hover-text-body":!this.disabled,"cursor-default text-disabled":this.disabled}),this.disabled,this.readonly||!this._value,this.__clear,l(v||(v=$`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1em; height: 1em; transform: scale(1.25); margin-right: -0.16em"><path d="M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" /></svg>`)),this.helperText,this.disabled||this.readonly||!this.__isErrorVisible,this._errorMessage,d(this._value||void 0),(()=>this.requestUpdate()))}__renderStandaloneLayout(){var e,t,s,i,r;const l=this.__valueLoader,u="string"==typeof this._value?n(this._value):void 0,c="string"==typeof this._value?null===(e=this.getItemUrl)||void 0===e?void 0:e.call(this,this._value,null!==(t=null==l?void 0:l.data)&&void 0!==t?t:null):void 0;return o(x||(x=$` <div class="block group"> <div class="${0}"> <span class="mr-auto text-l">${0}</span> ${0} ${0} ${0} </div> <div class="text-secondary text-s" ?hidden="${0}">${0}</div> <button class="${0}" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" ?disabled="${0}" @click="${0}"> <div class="${0}"> <foxy-nucleon class="block" infer="" href="${0}" id="valueLoader" @update="${0}"> ${0} </foxy-nucleon> </div> </button> <div class="mt-xs text-xs leading-xs text-error" ?hidden="${0}"> ${0} </div> </div> `),h({"flex items-center gap-s transition-colors font-medium":!0,"text-disabled":this.disabled}),this.label,c?o(b||(b=$` <a class="text-body rounded transition-opacity hover-opacity-90 focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}"> <foxy-i18n infer="" key="view"></foxy-i18n> </a> `),c):"",this.showCopyIdButton&&null!==u?o(_||(_=$` <foxy-copy-to-clipboard layout="text" theme="contrast tertiary-inline" infer="copy-id" text="${0}"> </foxy-copy-to-clipboard> `),u):"",this.readonly||!this._value?"":o(g||(g=$` <vaadin-button theme="error tertiary-inline" ?disabled="${0}" @click="${0}"> <foxy-i18n infer="" key="clear"></foxy-i18n> </vaadin-button> `),this.disabled,this.__clear),!this.helperText,this.helperText,h({"block w-full bg-contrast-5 rounded text-left transition-colors":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"cursor-pointer hover-bg-contrast-10":!this.disabled&&!this.readonly,"cursor-default":this.disabled||this.readonly,"mt-s":!!this.label||!!this.helperText}),this.disabled||this.readonly,(e=>{const t=e.currentTarget,s=this.renderRoot.querySelector("foxy-form-dialog");s.href="",s.show(t)}),h({"transition-opacity":!0,"opacity-50":this.disabled}),d(this._value||void 0),(()=>this.requestUpdate()),this.__getItemRenderer(this.item)({html:o,data:null!==(s=null==l?void 0:l.data)&&void 0!==s?s:null,href:this._value||"",related:[],parent:"",props:{},spread:a,simplifyNsLoading:this.simplifyNsLoading,disabled:this.disabled,disabledControls:this.disabledControls,readonly:this.readonly,readonlyControls:this.readonlyControls,hidden:this.hidden,hiddenControls:this.hiddenControls,templates:this.templates,previous:null,next:null,group:null!==(r=null===(i=this.nucleon)||void 0===i?void 0:i.group)&&void 0!==r?r:"",lang:this.lang,ns:this.ns}),!this._errorMessage||this.disabled||this.readonly,this._errorMessage)}__handleFetchEvent(e){if(!(e instanceof r))return;if(e.defaultPrevented)return;const{url:t,method:s}=e.request;return t===`foxy://${this.virtualHost}/select`&&"POST"===s?e.respondWith(this.__handleSelect(e.request)):t===`foxy://${this.virtualHost}/empty`&&"GET"===s?e.respondWith(this.__handleEmpty()):void 0}async __handleSelect(e){const t=await e.clone().json();return this._value=t.selection,new Response(JSON.stringify({_links:{self:{href:`foxy://${this.virtualHost}/empty`}},message:"Resource selected."}))}async __handleEmpty(){return new Response(JSON.stringify({_links:{self:{href:`foxy://${this.virtualHost}/empty`}},message:"Resource selected."}))}get __valueLoader(){return this.renderRoot.querySelector("#valueLoader")}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-56741bad.js";import"./shared-53a5212e.js";import"./shared-34262bb8.js";import"./shared-d8b880bb.js";import{I as e}from"./shared-
|
|
1
|
+
import"./shared-56741bad.js";import"./shared-53a5212e.js";import"./shared-34262bb8.js";import"./shared-d8b880bb.js";import{I as e}from"./shared-4ab85bea.js";import{_ as t}from"./shared-8f9014ff.js";import{c as i,h as a,s}from"./shared-ba5c42c7.js";import{i as l}from"./shared-53e42a77.js";import{c as o}from"./shared-4e709717.js";let n,r,d,h,u,c,p=e=>e;customElements.define("foxy-internal-frequency-control",class extends e{constructor(){super(...arguments),this.allowTwiceAMonth=!1,this.options=[{value:"d",label:"day"},{value:"w",label:"week"},{value:"m",label:"month"},{value:"y",label:"year"}],this.layout=null,this.max=999,this.__i18n={formatValue:e=>e.join(""),parseValue:e=>{var t;const i=e.startsWith(".")?`0${e}`:e,a=parseFloat(e.substring(0,Math.max(i.length-1,0))),s=null!==(t=i[i.length-1])&&void 0!==t?t:"";return isNaN(a)?["0",""]:[a.toString(),s]}}}static get properties(){return t(t({},super.properties),{},{allowTwiceAMonth:{type:Boolean,attribute:"allow-twice-a-month"},options:{attribute:!1},layout:{},max:{type:Number}})}static get styles(){return[super.styles,i(n||(n=p`:host{display:block}vaadin-custom-field{width:100%;font-size:0;line-height:0;padding-top:0!important}vaadin-custom-field::part(label){padding-bottom:var(--lumo-space-s)}vaadin-custom-field::part(error-message)[aria-hidden=false]{padding-top:var(--lumo-space-xs)}vaadin-combo-box,vaadin-integer-field{width:calc(50% - (var(--lumo-space-s)/ 2))}vaadin-integer-field{margin-right:var(--lumo-space-s);padding:0}vaadin-combo-box::part(text-field){padding:0}input::-webkit-inner-spin-button,input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input{-moz-appearance:textfield}`))]}renderControl(){var e,t;if("summary-item"===this.layout)return this.__renderSummaryItemLayout();const i=null!==(e=this._value)&&void 0!==e?e:"",s=parseFloat(this.__i18n.parseValue(i)[0]),o=this.options.map((({value:e,label:t})=>({label:this.t(t,{count:s}),value:e})));return a(r||(r=p` <vaadin-custom-field ?disabled="${0}" ?readonly="${0}" .checkValidity="${0}" .errorMessage="${0}" .helperText="${0}" .label="${0}" .value="${0}" .i18n="${0}" @change="${0}"> <vaadin-integer-field max="${0}" min="1" prevent-invalid-input has-controls ?disabled="${0}" ?readonly="${0}" ?invalid="${0}" @keydown="${0}"> </vaadin-integer-field> <vaadin-combo-box item-value-path="value" item-label-path="label" ?disabled="${0}" ?readonly="${0}" ?invalid="${0}" .items="${0}" @keydown="${0}"> </vaadin-combo-box> </vaadin-custom-field> `),this.disabled,this.readonly,this._checkValidity,null!==(t=this._errorMessage)&&void 0!==t?t:"",this.helperText,this.label,i,this.__i18n,(e=>{const t=e.currentTarget;this._value=t.value}),l(this.max||void 0),this.disabled,this.readonly,!this._checkValidity(),(e=>{var t;return"Enter"===e.key&&(null===(t=this.nucleon)||void 0===t?void 0:t.submit())}),this.disabled,this.readonly,!this._checkValidity(),o,(e=>{var t;return"Enter"===e.key&&(null===(t=this.nucleon)||void 0===t?void 0:t.submit())}))}updated(e){var t;super.updated(e);const i=this.renderRoot.querySelector("vaadin-custom-field");i&&i.value!==this._value&&(i.value=null!==(t=this._value)&&void 0!==t?t:"")}_handleHostClick(e){var t;if("summary-item"!==this.layout)return;const i=e.composedPath(),a=new Set(["INPUT","LABEL","SELECT"]);i.some((e=>a.has(e.tagName)))||(null===(t=this.renderRoot.querySelector("input"))||void 0===t||t.focus(),super._handleHostClick(e))}__renderSummaryItemLayout(){var e,t;const i=null!==(e=this._value)&&void 0!==e?e:"",[n,r]=this.__i18n.parseValue(i),m=parseFloat(n),v=".5m"!==this._value||this.allowTwiceAMonth?this.options.find((e=>e.value===r)):void 0;return a(d||(d=p` <div class="leading-xs"> <div class="flex items-center gap-xs"> <label class="text-m text-body flex-1 whitespace-nowrap" for="input">${0}</label> <input placeholder="${0}" inputmode="numeric" style="min-width:10ch" class="${0}" type="number" step="1" min="1" max="${0}" id="input" .value="${0}" ?disabled="${0}" ?readonly="${0}" @keydown="${0}" @input="${0}"> <div class="${0}"> <div class="flex items-center gap-xs"> <div class="whitespace-nowrap"> ${0} </div> ${0} </div> <select class="${0}" id="select" ?disabled="${0}" ?hidden="${0}" @change="${0}"> <option value="" ?selected="${0}" disabled="disabled" hidden>${0}</option> ${0} ${0} </select> </div> </div> <div style="max-width:32rem"> <p class="text-xs text-secondary">${0}</p> <p class="text-xs text-error" ?hidden="${0}"> ${0} </p> </div> </div> `),this.label,this.placeholder,o({"w-full appearance-none text-right bg-transparent transition-colors":!0,"text-m rounded-s focus-outline-none":!0,"text-secondary":this.readonly,"text-disabled":this.disabled,"font-medium":!this.readonly}),l(null!==(t=this.max)&&void 0!==t?t:void 0),".5m"===i?this.allowTwiceAMonth?2:"":m,this.disabled,this.readonly,(e=>{var t;return"Enter"===e.key&&(null===(t=this.nucleon)||void 0===t?void 0:t.submit())}),(e=>{e.stopPropagation();const t=e.currentTarget,i=r||this.options[0].value;this._value=this.__i18n.formatValue([t.value,i])}),o({"relative rounded-s transition-colors transition-opacity":!0,"focus-within-ring-2 focus-within-ring-primary-50":!this.disabled&&!this.readonly,"text-body hover-opacity-80 cursor-pointer":!this.disabled&&!this.readonly,"text-secondary":this.readonly,"text-disabled":this.disabled,"font-medium":!this.readonly}),".5m"===i?this.t("times_a_month"):v?this.t(v.label,{count:m}):this.t("select"),this.readonly?"":s(h||(h=p`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1em; height: 1em; transform: scale(1.25)"><path fill-rule="evenodd" d="M10.53 3.47a.75.75 0 0 0-1.06 0L6.22 6.72a.75.75 0 0 0 1.06 1.06L10 5.06l2.72 2.72a.75.75 0 1 0 1.06-1.06l-3.25-3.25Zm-4.31 9.81 3.25 3.25a.75.75 0 0 0 1.06 0l3.25-3.25a.75.75 0 1 0-1.06-1.06L10 14.94l-2.72-2.72a.75.75 0 0 0-1.06 1.06Z" clip-rule="evenodd" /></svg>`)),o({"absolute inset-0 opacity-0":!0,"cursor-pointer":!this.disabled&&!this.readonly}),this.disabled,this.readonly,(e=>{e.stopPropagation();const t=e.currentTarget.value;this._value="times_a_month"===t?".5m":this.__i18n.formatValue([m||1,t])}),!v,this.t("select"),!this.allowTwiceAMonth||2!==m&&".5m"!==i?"":a(u||(u=p` <option value="times_a_month" ?selected="${0}"> ${0} </option> `),".5m"===i,this.t("times_a_month")),this.options.map((e=>a(c||(c=p` <option value="${0}" ?selected="${0}"> ${0} </option> `),e.value,".5m"!==i&&e.value===(null==v?void 0:v.value),this.t(e.label,{count:m})))),this.helperText,this.disabled||this.readonly,this._errorMessage)}});
|
|
@@ -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": {
|
|
@@ -114,6 +114,10 @@
|
|
|
114
114
|
"resend": "Resend",
|
|
115
115
|
"checked": "Granted",
|
|
116
116
|
"unchecked": "Not granted",
|
|
117
|
+
"included-resend": {
|
|
118
|
+
"checked": "Included with full access",
|
|
119
|
+
"unchecked": "Not granted"
|
|
120
|
+
},
|
|
117
121
|
"scopes": {
|
|
118
122
|
"carts": "Carts",
|
|
119
123
|
"coupons": "Coupons",
|
|
@@ -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,CAA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AI,CAAC,GAAG,EAAE,CAAC,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,EA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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"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';
|
|
2
2
|
import { InternalEditableControl } from '../../../../internal/InternalEditableControl/InternalEditableControl';
|
|
3
|
+
import { BooleanSelector } from '@foxy.io/sdk/core';
|
|
3
4
|
/**
|
|
4
5
|
* Lets an admin choose which scopes an invitation grants, offering only what the granting
|
|
5
6
|
* user already holds.
|
|
@@ -58,6 +59,7 @@ export declare class InternalUserInvitationFormScopeControl extends InternalEdit
|
|
|
58
59
|
* update independently of this method.
|
|
59
60
|
*/
|
|
60
61
|
updated(changes: Map<keyof this, unknown>): void;
|
|
62
|
+
get readonlySelector(): BooleanSelector;
|
|
61
63
|
/**
|
|
62
64
|
* `true` when the invitation already holds something this granter could not themselves
|
|
63
65
|
* grant: the current preset isn't among the ones offered, a collection's current level
|
|
@@ -80,8 +82,9 @@ export declare class InternalUserInvitationFormScopeControl extends InternalEdit
|
|
|
80
82
|
/**
|
|
81
83
|
* Renders the three resendable collections' resend grants as `foxy-internal-switch-control`s,
|
|
82
84
|
* one per line, in their own `foxy-internal-summary-control` -- not folded into the level
|
|
83
|
-
* grid above. Resend is a secondary
|
|
84
|
-
* grant are unrelated tokens -- see `parseScope`/`serializeScope
|
|
85
|
+
* grid above. Resend is a secondary axis (below Full, a collection's level and its resend
|
|
86
|
+
* grant are unrelated tokens -- see `parseScope`/`serializeScope`; Full includes resend, so the
|
|
87
|
+
* switch then shows as on and readonly), covers only 3 of the 20
|
|
85
88
|
* collections, and doesn't need the level grid's two-column treatment; keeping it as its own
|
|
86
89
|
* section also means the grid's CSS (sized for 20 short rows) never has to accommodate a
|
|
87
90
|
* structurally different kind of row. Renders nothing at all if the granter can't grant (and
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InternalEditableControl } from "../../../../internal/InternalEditableControl/InternalEditableControl.js";
|
|
2
2
|
import { COLLECTIONS, RESENDABLE } from "../../../../../utils/group-invitation-scopes.js";
|
|
3
|
+
import { BooleanSelector } from '@foxy.io/sdk/core';
|
|
3
4
|
import { css } from 'lit-element';
|
|
4
5
|
import { html } from 'lit-html';
|
|
5
6
|
import { canGrantLevel, canGrantReadPreset, canGrantResend, getGrantable, parseScope, serializeScope, } from "../../../../../utils/invitation-scope.js";
|
|
@@ -166,6 +167,11 @@ export class InternalUserInvitationFormScopeControl extends InternalEditableCont
|
|
|
166
167
|
if (this.__isLocked && !this.readonly)
|
|
167
168
|
this.readonly = true;
|
|
168
169
|
}
|
|
170
|
+
// A resend switch at Full is inferred as `included-resend`, so it can be readonly on its own:
|
|
171
|
+
// a `?readonly=` binding on it would be overwritten by inference, as `updated()` describes.
|
|
172
|
+
get readonlySelector() {
|
|
173
|
+
return new BooleanSelector(`${super.readonlySelector.toString()} included-resend`.trim());
|
|
174
|
+
}
|
|
169
175
|
/**
|
|
170
176
|
* `true` when the invitation already holds something this granter could not themselves
|
|
171
177
|
* grant: the current preset isn't among the ones offered, a collection's current level
|
|
@@ -268,8 +274,9 @@ export class InternalUserInvitationFormScopeControl extends InternalEditableCont
|
|
|
268
274
|
/**
|
|
269
275
|
* Renders the three resendable collections' resend grants as `foxy-internal-switch-control`s,
|
|
270
276
|
* one per line, in their own `foxy-internal-summary-control` -- not folded into the level
|
|
271
|
-
* grid above. Resend is a secondary
|
|
272
|
-
* grant are unrelated tokens -- see `parseScope`/`serializeScope
|
|
277
|
+
* grid above. Resend is a secondary axis (below Full, a collection's level and its resend
|
|
278
|
+
* grant are unrelated tokens -- see `parseScope`/`serializeScope`; Full includes resend, so the
|
|
279
|
+
* switch then shows as on and readonly), covers only 3 of the 20
|
|
273
280
|
* collections, and doesn't need the level grid's two-column treatment; keeping it as its own
|
|
274
281
|
* section also means the grid's CSS (sized for 20 short rows) never has to accommodate a
|
|
275
282
|
* structurally different kind of row. Renders nothing at all if the granter can't grant (and
|
|
@@ -277,6 +284,7 @@ export class InternalUserInvitationFormScopeControl extends InternalEditableCont
|
|
|
277
284
|
*/
|
|
278
285
|
__renderResendSwitches(selection, grantable, readonly) {
|
|
279
286
|
const switches = RESENDABLE.map(collection => {
|
|
287
|
+
const included = selection.levels[collection] === 'full';
|
|
280
288
|
const hasResend = selection.resend.includes(collection);
|
|
281
289
|
const canResend = canGrantResend(grantable, collection);
|
|
282
290
|
// Mirrors the level mismatch in `__renderLevelControl`: the invitation can already carry
|
|
@@ -289,15 +297,21 @@ export class InternalUserInvitationFormScopeControl extends InternalEditableCont
|
|
|
289
297
|
// property subject to the exact same ancestor-inference-can-overwrite-a-template-binding
|
|
290
298
|
// risk documented on this control's own `updated()`, for a case that can't actually occur.
|
|
291
299
|
const mismatchedResend = hasResend && !canResend;
|
|
292
|
-
return {
|
|
300
|
+
return {
|
|
301
|
+
collection,
|
|
302
|
+
included,
|
|
303
|
+
hasResend: hasResend || included,
|
|
304
|
+
mismatchedResend,
|
|
305
|
+
show: canResend || mismatchedResend || included,
|
|
306
|
+
};
|
|
293
307
|
}).filter(entry => entry.show);
|
|
294
308
|
if (!switches.length)
|
|
295
309
|
return '';
|
|
296
310
|
return html `
|
|
297
311
|
<foxy-internal-summary-control infer="" label="" helper-text="">
|
|
298
|
-
${switches.map(({ collection, hasResend }) => html `
|
|
312
|
+
${switches.map(({ collection, included, hasResend }) => html `
|
|
299
313
|
<foxy-internal-switch-control
|
|
300
|
-
infer
|
|
314
|
+
infer=${included ? 'included-resend' : ''}
|
|
301
315
|
label=${`${this.t('resend')} ${this.t(`scopes.${collection}`).toLowerCase()}`}
|
|
302
316
|
helper-text=""
|
|
303
317
|
data-resend=${collection}
|
|
@@ -318,8 +332,14 @@ export class InternalUserInvitationFormScopeControl extends InternalEditableCont
|
|
|
318
332
|
// matrix would vanish out from under the admin mid-edit.
|
|
319
333
|
this.__customSelected = true;
|
|
320
334
|
const selection = parseScope(this.__scope);
|
|
335
|
+
const crossesFull = level === 'full' || selection.levels[collection] === 'full';
|
|
321
336
|
selection.levels[collection] = level;
|
|
322
|
-
|
|
337
|
+
// Full includes resend, so the switch shows the same at Full with or without the token.
|
|
338
|
+
// Dropping it here means leaving Full always clears resend, whichever way it was stored.
|
|
339
|
+
const resend = crossesFull
|
|
340
|
+
? selection.resend.filter(entry => entry !== collection)
|
|
341
|
+
: selection.resend;
|
|
342
|
+
this._value = serializeScope({ ...selection, preset: 'custom', resend });
|
|
323
343
|
}
|
|
324
344
|
__setResend(collection, checked) {
|
|
325
345
|
this.__customSelected = true;
|
|
@@ -350,14 +370,14 @@ export class InternalUserInvitationFormScopeControl extends InternalEditableCont
|
|
|
350
370
|
this.__customSelected = preset === 'custom';
|
|
351
371
|
// Choosing Custom keeps whatever is already in the form, so the matrix opens on the
|
|
352
372
|
// current grant rather than wiping it. The wildcard has no per-row levels, so it is
|
|
353
|
-
// expanded into what it grants -- every collection at Full
|
|
373
|
+
// expanded into what it grants -- every collection at Full, which includes resend. Keeping
|
|
354
374
|
// `store_full_access` behind rows that all read None would save a full-access invitation.
|
|
355
375
|
if (preset === 'custom') {
|
|
356
376
|
const selection = parseScope(this.__scope);
|
|
357
377
|
if (selection.preset !== 'store')
|
|
358
378
|
return;
|
|
359
379
|
COLLECTIONS.forEach(collection => (selection.levels[collection] = 'full'));
|
|
360
|
-
this._value = serializeScope({ ...selection, preset: 'custom'
|
|
380
|
+
this._value = serializeScope({ ...selection, preset: 'custom' });
|
|
361
381
|
return;
|
|
362
382
|
}
|
|
363
383
|
if (preset === 'store') {
|