@foxy.io/elements 1.59.0 → 1.60.1
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-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-a44fcc6a.js → shared-ad5617ef.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/user-invitation-form/en.json +4 -0
- package/dist/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.js +3 -3
- package/dist/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.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-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)}});
|
|
@@ -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",
|
|
@@ -137,9 +137,9 @@ export class AdminSubscriptionCard extends Base {
|
|
|
137
137
|
: html `​`}
|
|
138
138
|
</div>
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
<div class="text-tertiary truncate text-s">
|
|
141
|
+
${customerLine ? customerLine : html `​`}
|
|
142
|
+
</div>
|
|
143
143
|
</div>
|
|
144
144
|
`;
|
|
145
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminSubscriptionCard.js","sourceRoot":"","sources":["../../../../src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,qCAAkC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,kDAA+C;AAC/E,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAChE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,yBAAyB,CAAC;AACrC,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,OAAO,qBAAsB,SAAQ,IAAU;IAArD;;QAQE;;;;WAIG;QACH,gBAAW,GAAkB,IAAI,CAAC;QAEjB,kCAA6B,GAAG,2BAA2B,CAAC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B,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAC/C,IAAI,eAAe,KAAK,SAAS;YAAE,OAAO;QAE1C,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,MAAM,UAAU,SAAG,IAAI,CAAC,qBAAqB,0CAAE,WAAW,CAAC;QAC3D,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO;QAErC,MAAM,SAAS,SAAG,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC;QACvC,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO;QAEpC,OAAO;YACL,GAAG,cAAc,CAAC,SAAS,CAAC;YAC5B,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,GAAG,UAAU,EAAE;YACxE,eAAe;SAChB,CAAC;IACJ,CAAC;IAED,IAAY,UAAU;;QACpB,MAAM,SAAS,SAAG,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC;QACvC,IAAI,SAAS;YAAE,OAAO,SAAS,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACvF,CAAC;CACF","sourcesContent":["import type { ScopeCollection } from '../../../utils/user-scope';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { canReadCollection } from '../../../utils/user-scope';\nimport { getSubscriptionStatus } from '../../../utils/get-subscription-status';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { getResourceId } from '@foxy.io/sdk/core';\nimport { html } from 'lit-html';\n\nconst NS = 'admin-subscription-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Card element representing a subscription (`fx:subscription`).\n * Admin-only.\n *\n * @element foxy-admin-subscription-card\n * @since 1.21.0\n */\nexport class AdminSubscriptionCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n localeCodes: { attribute: 'locale-codes' },\n };\n }\n\n /**\n * URL of the `fx:locale_codes` property helper.\n * This will be used to determine the currency code for subscriptions that link to a\n * transaction template without the code.\n */\n localeCodes: string | null = null;\n\n private readonly __transactionTemplateLoaderId = 'transactionTemplateLoader';\n\n private readonly __defaultTemplateSetLoaderId = 'defaultTemplateSetLoader';\n\n private readonly __localeCodesHelperLoaderId = 'localeCodesLoader';\n\n private readonly __templateSetLoaderId = 'templateSetLoader';\n\n private readonly __customerLoaderId = 'customerLoader';\n\n private readonly __itemsLoaderId = 'itemsLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n get scopeCollection(): ScopeCollection | null {\n return 'subscriptions';\n }\n\n renderBody(): TemplateResult {\n const customer = this.__customer;\n const cart = this.__transactionTemplate;\n\n const priceKey = this.__priceKey;\n const priceOptions = this.__priceOptions;\n const summaryOptions = this.__summaryOptions;\n const summaryKey = this.__summaryKey;\n const status = getSubscriptionStatus(this.data);\n\n const name = [customer?.first_name, customer?.last_name].filter(v => !!v).join(' ');\n const email = cart?.customer_email;\n const customerLine = name && email ? `${name} (${email})` : name || email;\n\n return html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionTemplateHref)}\n id=${this.__transactionTemplateLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__defaultTemplateSetHref)}\n id=${this.__defaultTemplateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__localeCodesHelperHref)}\n id=${this.__localeCodesHelperLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__templateSetHref)}\n id=${this.__templateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__customerHref)}\n id=${this.__customerLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__itemsHref)}\n id=${this.__itemsLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__storeHref)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div class=\"text-left leading-s text-tertiary\">\n <div class=\"flex items-center space-x-s\">\n <span class=\"block flex-1 font-medium text-body truncate\">\n ${summaryOptions && summaryKey\n ? html`<foxy-i18n infer=\"\" key=${summaryKey} .options=${summaryOptions}></foxy-i18n>`\n : html`​`}\n </span>\n <span class=\"text-s\">\n ${priceOptions && priceKey\n ? html`<foxy-i18n infer=\"\" key=${priceKey} .options=${priceOptions}></foxy-i18n>`\n : html`​`}\n </span>\n </div>\n\n <div class=\"truncate text-s ${status === 'failed' ? 'text-error' : 'text-secondary'}\">\n ${this.data && status\n ? html`<foxy-i18n infer=\"\" key=\"status_${status}\" .options=${this.data}></foxy-i18n>`\n : html`​`}\n </div>\n\n ${customerLine\n ? html`<div class=\"text-tertiary truncate text-s\">${customerLine}</div>`\n : ''}\n </div>\n `;\n }\n\n get isBodyReady(): boolean {\n // Helpers the scope can't read never load, so the card renders without them.\n const can = (collection: ScopeCollection) => {\n return canReadCollection(this.currentUserScope, collection);\n };\n\n const cart = this.__transactionTemplate;\n const isCodeUnreachable =\n !can('carts') ||\n (!!cart &&\n !cart.currency_code &&\n (!can('templates') || (cart.template_set_uri === '' && !can('stores'))));\n\n return (\n super.isBodyReady &&\n (!!this.__items || !can('carts')) &&\n (!!this.__currencyCode || isCodeUnreachable) &&\n !!this.__currencyDisplay &&\n (!!this.__customer || !can('customers'))\n );\n }\n\n private get __transactionTemplateHref() {\n const data = this.data;\n\n if (!data || !canReadCollection(this.currentUserScope, 'carts')) return;\n if ('_embedded' in data && 'fx:transaction_template' in data._embedded) return;\n\n const url = new URL(this.data?._links['fx:transaction_template'].href ?? '');\n url.searchParams.set('zoom', 'items');\n return url.toString();\n }\n\n private get __defaultTemplateSetHref() {\n const templateSetUri = this.__transactionTemplate?.template_set_uri;\n\n if (templateSetUri === '') {\n try {\n const url = new URL(this.__store?._links['fx:template_sets'].href ?? '');\n url.searchParams.set('code', 'DEFAULT');\n return url.toString();\n } catch {\n //\n }\n }\n }\n\n private get __localeCodesHelperHref() {\n if (this.__defaultTemplateSetHref || this.__templateSetHref) {\n return this.localeCodes ?? void 0;\n }\n }\n\n private get __templateSetHref() {\n const cart = this.__transactionTemplate;\n if (!cart?.currency_code) return cart?.template_set_uri || void 0;\n }\n\n private get __customerHref() {\n if ('fx:customer' in (this.data?._embedded ?? {})) return;\n if (!canReadCollection(this.currentUserScope, 'customers')) return;\n return this.data?._links['fx:customer']?.href;\n }\n\n private get __itemsHref() {\n const cart = this.__transactionTemplate;\n\n if (!cart) return;\n if ('_embedded' in cart && 'fx:items' in cart._embedded) return;\n\n const url = new URL(cart._links['fx:items'].href);\n url.searchParams.set('limit', '1');\n return url.toString();\n }\n\n private get __storeHref() {\n if (!canReadCollection(this.currentUserScope, 'stores')) return;\n return this.data?._links['fx:store']?.href;\n }\n\n private get __transactionTemplate() {\n const data = this.data;\n\n if (data && '_embedded' in data && 'fx:transaction_template' in data._embedded) {\n type Cart = Resource<Rels.TransactionTemplate>;\n type CartWithItems = Resource<Rels.TransactionTemplate, { zoom: 'items' }>;\n return data._embedded['fx:transaction_template'] as Cart | CartWithItems;\n } else {\n type Loader = NucleonElement<Resource<Rels.TransactionTemplate, { zoom: 'items' }>>;\n const selector = `#${this.__transactionTemplateLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n }\n\n private get __defaultTemplateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSets>>;\n const selector = `#${this.__defaultTemplateSetLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:template_sets'][0] ?? null;\n }\n\n private get __localeCodesHelper() {\n type Loader = NucleonElement<Resource<Rels.LocaleCodes>>;\n const selector = `#${this.__localeCodesHelperLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __templateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSet>>;\n const selector = `#${this.__templateSetLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __customer() {\n const data = this.data;\n\n if (data && '_embedded' in data && 'fx:customer' in data._embedded) {\n return data._embedded['fx:customer'] as Resource<Rels.Customer>;\n } else {\n type Loader = NucleonElement<Resource<Rels.Customer>>;\n const selector = `#${this.__customerLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n }\n\n private get __items() {\n type Cart = Resource<Rels.TransactionTemplate>;\n type CartWithItems = Resource<Rels.TransactionTemplate, { zoom: 'items' }>;\n\n const cart = this.__transactionTemplate as Cart | CartWithItems | null;\n\n if (cart && '_embedded' in cart && 'fx:items' in cart._embedded) {\n const items = cart._embedded['fx:items'];\n\n return {\n array: items,\n count: items.length,\n isApproximateCount: items.length === 20,\n };\n }\n\n type Loader = NucleonElement<Resource<Rels.Items>>;\n const loader = this.renderRoot.querySelector<Loader>(`#${this.__itemsLoaderId}`);\n if (!loader?.data) return null;\n\n return {\n array: loader.data._embedded['fx:items'],\n count: loader.data.total_items,\n isApproximateCount: false,\n };\n }\n\n private get __store() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n const selector = `#${this.__storeLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __currencyDisplay() {\n const useCode = this.__store?.use_international_currency_symbol;\n\n if (useCode === true) return 'code';\n if (useCode === false) return 'symbol';\n if (!canReadCollection(this.currentUserScope, 'stores')) return 'symbol';\n }\n\n private get __summaryOptions() {\n const { array, count } = this.__items ?? {};\n if (array && count) return { firstItem: array[0], count, countMinus1: count - 1 };\n // The first line must never be blank, e.g. when the scope can't read carts.\n const self = this.data?._links.self.href;\n if (self) return { id: getResourceId(self) };\n }\n\n private get __summaryKey() {\n const items = this.__items;\n if (items?.count) return items.isApproximateCount ? 'summary_approximate' : 'summary';\n if (this.data) return 'summary_fallback';\n }\n\n private get __currencyCode() {\n const cart = this.__transactionTemplate;\n\n if (cart?.currency_code) {\n return cart.currency_code as string;\n } else {\n const allLocaleCodes = this.__localeCodesHelper;\n const localeCode = (this.__templateSet ?? this.__defaultTemplateSet)?.locale_code;\n const localeInfo = localeCode ? allLocaleCodes?.values[localeCode] : void 0;\n\n if (localeInfo) return /Currency: ([A-Z]{3})/g.exec(localeInfo)?.[1];\n }\n }\n\n private get __priceOptions() {\n const currencyDisplay = this.__currencyDisplay;\n if (currencyDisplay === undefined) return;\n\n const currencyCode = this.__currencyCode;\n const totalOrder = this.__transactionTemplate?.total_order;\n if (totalOrder === undefined) return;\n\n const frequency = this.data?.frequency;\n if (frequency === undefined) return;\n\n return {\n ...parseFrequency(frequency),\n amount: currencyCode ? `${totalOrder} ${currencyCode}` : `${totalOrder}`,\n currencyDisplay,\n };\n }\n\n private get __priceKey() {\n const frequency = this.data?.frequency;\n if (frequency) return `price_${frequency === '.5m' ? 'twice_a_month' : 'recurring'}`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AdminSubscriptionCard.js","sourceRoot":"","sources":["../../../../src/elements/public/AdminSubscriptionCard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CAAC;IAED,IAAY,UAAU;;QACpB,MAAM,SAAS,SAAG,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC;QACvC,IAAI,SAAS;YAAE,OAAO,SAAS,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACvF,CAAC;CACF","sourcesContent":["import type { ScopeCollection } from '../../../utils/user-scope';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { canReadCollection } from '../../../utils/user-scope';\nimport { getSubscriptionStatus } from '../../../utils/get-subscription-status';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { getResourceId } from '@foxy.io/sdk/core';\nimport { html } from 'lit-html';\n\nconst NS = 'admin-subscription-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Card element representing a subscription (`fx:subscription`).\n * Admin-only.\n *\n * @element foxy-admin-subscription-card\n * @since 1.21.0\n */\nexport class AdminSubscriptionCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n localeCodes: { attribute: 'locale-codes' },\n };\n }\n\n /**\n * URL of the `fx:locale_codes` property helper.\n * This will be used to determine the currency code for subscriptions that link to a\n * transaction template without the code.\n */\n localeCodes: string | null = null;\n\n private readonly __transactionTemplateLoaderId = 'transactionTemplateLoader';\n\n private readonly __defaultTemplateSetLoaderId = 'defaultTemplateSetLoader';\n\n private readonly __localeCodesHelperLoaderId = 'localeCodesLoader';\n\n private readonly __templateSetLoaderId = 'templateSetLoader';\n\n private readonly __customerLoaderId = 'customerLoader';\n\n private readonly __itemsLoaderId = 'itemsLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n get scopeCollection(): ScopeCollection | null {\n return 'subscriptions';\n }\n\n renderBody(): TemplateResult {\n const customer = this.__customer;\n const cart = this.__transactionTemplate;\n\n const priceKey = this.__priceKey;\n const priceOptions = this.__priceOptions;\n const summaryOptions = this.__summaryOptions;\n const summaryKey = this.__summaryKey;\n const status = getSubscriptionStatus(this.data);\n\n const name = [customer?.first_name, customer?.last_name].filter(v => !!v).join(' ');\n const email = cart?.customer_email;\n const customerLine = name && email ? `${name} (${email})` : name || email;\n\n return html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionTemplateHref)}\n id=${this.__transactionTemplateLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__defaultTemplateSetHref)}\n id=${this.__defaultTemplateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__localeCodesHelperHref)}\n id=${this.__localeCodesHelperLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__templateSetHref)}\n id=${this.__templateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__customerHref)}\n id=${this.__customerLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__itemsHref)}\n id=${this.__itemsLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__storeHref)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div class=\"text-left leading-s text-tertiary\">\n <div class=\"flex items-center space-x-s\">\n <span class=\"block flex-1 font-medium text-body truncate\">\n ${summaryOptions && summaryKey\n ? html`<foxy-i18n infer=\"\" key=${summaryKey} .options=${summaryOptions}></foxy-i18n>`\n : html`​`}\n </span>\n <span class=\"text-s\">\n ${priceOptions && priceKey\n ? html`<foxy-i18n infer=\"\" key=${priceKey} .options=${priceOptions}></foxy-i18n>`\n : html`​`}\n </span>\n </div>\n\n <div class=\"truncate text-s ${status === 'failed' ? 'text-error' : 'text-secondary'}\">\n ${this.data && status\n ? html`<foxy-i18n infer=\"\" key=\"status_${status}\" .options=${this.data}></foxy-i18n>`\n : html`​`}\n </div>\n\n <div class=\"text-tertiary truncate text-s\">\n ${customerLine ? customerLine : html`​`}\n </div>\n </div>\n `;\n }\n\n get isBodyReady(): boolean {\n // Helpers the scope can't read never load, so the card renders without them.\n const can = (collection: ScopeCollection) => {\n return canReadCollection(this.currentUserScope, collection);\n };\n\n const cart = this.__transactionTemplate;\n const isCodeUnreachable =\n !can('carts') ||\n (!!cart &&\n !cart.currency_code &&\n (!can('templates') || (cart.template_set_uri === '' && !can('stores'))));\n\n return (\n super.isBodyReady &&\n (!!this.__items || !can('carts')) &&\n (!!this.__currencyCode || isCodeUnreachable) &&\n !!this.__currencyDisplay &&\n (!!this.__customer || !can('customers'))\n );\n }\n\n private get __transactionTemplateHref() {\n const data = this.data;\n\n if (!data || !canReadCollection(this.currentUserScope, 'carts')) return;\n if ('_embedded' in data && 'fx:transaction_template' in data._embedded) return;\n\n const url = new URL(this.data?._links['fx:transaction_template'].href ?? '');\n url.searchParams.set('zoom', 'items');\n return url.toString();\n }\n\n private get __defaultTemplateSetHref() {\n const templateSetUri = this.__transactionTemplate?.template_set_uri;\n\n if (templateSetUri === '') {\n try {\n const url = new URL(this.__store?._links['fx:template_sets'].href ?? '');\n url.searchParams.set('code', 'DEFAULT');\n return url.toString();\n } catch {\n //\n }\n }\n }\n\n private get __localeCodesHelperHref() {\n if (this.__defaultTemplateSetHref || this.__templateSetHref) {\n return this.localeCodes ?? void 0;\n }\n }\n\n private get __templateSetHref() {\n const cart = this.__transactionTemplate;\n if (!cart?.currency_code) return cart?.template_set_uri || void 0;\n }\n\n private get __customerHref() {\n if ('fx:customer' in (this.data?._embedded ?? {})) return;\n if (!canReadCollection(this.currentUserScope, 'customers')) return;\n return this.data?._links['fx:customer']?.href;\n }\n\n private get __itemsHref() {\n const cart = this.__transactionTemplate;\n\n if (!cart) return;\n if ('_embedded' in cart && 'fx:items' in cart._embedded) return;\n\n const url = new URL(cart._links['fx:items'].href);\n url.searchParams.set('limit', '1');\n return url.toString();\n }\n\n private get __storeHref() {\n if (!canReadCollection(this.currentUserScope, 'stores')) return;\n return this.data?._links['fx:store']?.href;\n }\n\n private get __transactionTemplate() {\n const data = this.data;\n\n if (data && '_embedded' in data && 'fx:transaction_template' in data._embedded) {\n type Cart = Resource<Rels.TransactionTemplate>;\n type CartWithItems = Resource<Rels.TransactionTemplate, { zoom: 'items' }>;\n return data._embedded['fx:transaction_template'] as Cart | CartWithItems;\n } else {\n type Loader = NucleonElement<Resource<Rels.TransactionTemplate, { zoom: 'items' }>>;\n const selector = `#${this.__transactionTemplateLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n }\n\n private get __defaultTemplateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSets>>;\n const selector = `#${this.__defaultTemplateSetLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:template_sets'][0] ?? null;\n }\n\n private get __localeCodesHelper() {\n type Loader = NucleonElement<Resource<Rels.LocaleCodes>>;\n const selector = `#${this.__localeCodesHelperLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __templateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSet>>;\n const selector = `#${this.__templateSetLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __customer() {\n const data = this.data;\n\n if (data && '_embedded' in data && 'fx:customer' in data._embedded) {\n return data._embedded['fx:customer'] as Resource<Rels.Customer>;\n } else {\n type Loader = NucleonElement<Resource<Rels.Customer>>;\n const selector = `#${this.__customerLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n }\n\n private get __items() {\n type Cart = Resource<Rels.TransactionTemplate>;\n type CartWithItems = Resource<Rels.TransactionTemplate, { zoom: 'items' }>;\n\n const cart = this.__transactionTemplate as Cart | CartWithItems | null;\n\n if (cart && '_embedded' in cart && 'fx:items' in cart._embedded) {\n const items = cart._embedded['fx:items'];\n\n return {\n array: items,\n count: items.length,\n isApproximateCount: items.length === 20,\n };\n }\n\n type Loader = NucleonElement<Resource<Rels.Items>>;\n const loader = this.renderRoot.querySelector<Loader>(`#${this.__itemsLoaderId}`);\n if (!loader?.data) return null;\n\n return {\n array: loader.data._embedded['fx:items'],\n count: loader.data.total_items,\n isApproximateCount: false,\n };\n }\n\n private get __store() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n const selector = `#${this.__storeLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __currencyDisplay() {\n const useCode = this.__store?.use_international_currency_symbol;\n\n if (useCode === true) return 'code';\n if (useCode === false) return 'symbol';\n if (!canReadCollection(this.currentUserScope, 'stores')) return 'symbol';\n }\n\n private get __summaryOptions() {\n const { array, count } = this.__items ?? {};\n if (array && count) return { firstItem: array[0], count, countMinus1: count - 1 };\n // The first line must never be blank, e.g. when the scope can't read carts.\n const self = this.data?._links.self.href;\n if (self) return { id: getResourceId(self) };\n }\n\n private get __summaryKey() {\n const items = this.__items;\n if (items?.count) return items.isApproximateCount ? 'summary_approximate' : 'summary';\n if (this.data) return 'summary_fallback';\n }\n\n private get __currencyCode() {\n const cart = this.__transactionTemplate;\n\n if (cart?.currency_code) {\n return cart.currency_code as string;\n } else {\n const allLocaleCodes = this.__localeCodesHelper;\n const localeCode = (this.__templateSet ?? this.__defaultTemplateSet)?.locale_code;\n const localeInfo = localeCode ? allLocaleCodes?.values[localeCode] : void 0;\n\n if (localeInfo) return /Currency: ([A-Z]{3})/g.exec(localeInfo)?.[1];\n }\n }\n\n private get __priceOptions() {\n const currencyDisplay = this.__currencyDisplay;\n if (currencyDisplay === undefined) return;\n\n const currencyCode = this.__currencyCode;\n const totalOrder = this.__transactionTemplate?.total_order;\n if (totalOrder === undefined) return;\n\n const frequency = this.data?.frequency;\n if (frequency === undefined) return;\n\n return {\n ...parseFrequency(frequency),\n amount: currencyCode ? `${totalOrder} ${currencyCode}` : `${totalOrder}`,\n currencyDisplay,\n };\n }\n\n private get __priceKey() {\n const frequency = this.data?.frequency;\n if (frequency) return `price_${frequency === '.5m' ? 'twice_a_month' : 'recurring'}`;\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') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalUserInvitationFormScopeControl.js","sourceRoot":"","sources":["../../../../../../src/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,gFAA6E;AAC/G,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,wDAAqD;AACvF,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,GACf,iDAA8C;AAI/C;;;;;;;;;GASG;AACH,MAAM,OAAO,sCAAuC,SAAQ,uBAAuB;IAAnF;;QAsEE,4EAA4E;QAC5E,iBAAY,GAAkB,IAAI,CAAC;QAEnC;;;;WAIG;QACK,qBAAgB,GAAG,KAAK,CAAC;QAEjC;;;;WAIG;QACK,eAAU,GAAG,KAAK,CAAC;IAiW7B,CAAC;IArbC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,YAAY,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE;YAC5C,gBAAgB,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SACvC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,GAAG,KAAK,CAAC,MAAM;YACf,GAAG;;;;;;;;;;;;;;;;;;OAsDF;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;IAC1B,CAAC;IAEO,cAAc,CAAC,MAAc;QACnC,IAAI,CAAC,gBAAgB,GAAG,MAAM,KAAK,QAAQ,CAAC;QAE5C,oFAAoF;QACpF,oFAAoF;QACpF,qFAAqF;QACrF,0FAA0F;QAC1F,IAAI,MAAM,KAAK,QAAQ,EAAE;YACvB,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3C,IAAI,SAAS,CAAC,MAAM,KAAK,OAAO;gBAAE,OAAO;YAEzC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAC3E,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;YAC1F,OAAO;SACR;QAED,IAAI,MAAM,KAAK,OAAO,EAAE;YACtB,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC;SACnC;aAAM;YACL,MAAM,SAAS,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;YACjC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAC3E,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;SACzC;IACH,CAAC;CACF","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Option } from '../../../../internal/InternalSelectControl/types';\nimport type { Level, Selection } from '../../../../../utils/invitation-scope';\n\nimport { InternalEditableControl } from '../../../../internal/InternalEditableControl/InternalEditableControl';\nimport { COLLECTIONS, RESENDABLE } from '../../../../../utils/group-invitation-scopes';\nimport { css } from 'lit-element';\nimport { html } from 'lit-html';\n\nimport {\n canGrantLevel,\n canGrantReadPreset,\n canGrantResend,\n getGrantable,\n parseScope,\n serializeScope,\n} from '../../../../../utils/invitation-scope';\n\ntype Preset = 'store' | 'read' | 'custom';\n\n/**\n * Lets an admin choose which scopes an invitation grants, offering only what the granting\n * user already holds.\n *\n * Bound to the invitation's `scope` string through `infer=\"scope\"`. The server is the real\n * enforcement boundary; this control exists so the UI\n * never offers a grant that would be rejected.\n *\n * @element foxy-internal-user-invitation-form-scope-control\n */\nexport class InternalUserInvitationFormScopeControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n granterScope: { attribute: 'granter-scope' },\n __customSelected: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n /*\n * \\`foxy-internal-summary-control\\` puts \\`::slotted(*) { min-width: 100% }\\` on\n * whatever it slots, and (outside \\`layout=\"section\"\\`) a background/padding on each\n * slotted element too -- both aimed at a vertical list of full-width summary-items, and\n * both outside this control's reach: they're declared against the *slotted* elements\n * from the summary control's own shadow tree, not against anything inside this one, so\n * there is no selector this control's own \\`static styles\\` could write that would stop\n * a slotted element from being full-width, and the grid that would need a second\n * \\`grid-template-columns\\` track lives inside the summary control's own shadow root --\n * not reachable at all from here (confirmed: a \\`::slotted(*)\\` rule only ever targets\n * the slotted elements themselves, never the host's own internal structure around the\n * \\`<slot>\\`). So overriding a rule of ours against the slotted elements, per CSS\n * Scoping's normal-declarations-in-the-tree-the-element-lives-in-beat-::slotted()-rule\n * precedence, can only ever affect how each *individual* slotted box is sized -- it\n * cannot make the summary control itself lay two of them out side by side, because nothing\n * this control writes can reach that summary control's own internal grid container.\n *\n * So there is exactly one slotted child here: \\`.matrix\\`, a wrapper \\`<div>\\` (see\n * \\`renderControl\\`) that lays its own 20 real children out in a grid this control fully\n * owns. \\`layout=\"section\"\\` on the summary control (see \\`renderControl\\`) opts out of its\n * background/padding-on-slotted-child rule, since that would otherwise tint the *whole*\n * wrapper as one block; this control re-creates the summary-item tile look itself, on\n * each *individual* row, below.\n */\n .matrix {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 1px;\n border-radius: var(--lumo-border-radius);\n overflow: hidden;\n }\n\n @media all and (min-width: 640px) {\n .matrix {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n }\n }\n\n /*\n * Each row is one \\`foxy-internal-select-control[layout=\"summary-item\"]\\`, a single\n * self-contained element (see \\`__renderLevelControl\\`) -- no more per-row wrapper,\n * sibling label, or separate checkbox. Its own background here (rather than\n * \\`::slotted(*)\\`'s, opted out of above) is what recreates the individual-tile look;\n * the 1px \\`.matrix\\` gap on top of \\`var(--lumo-contrast-10pct)\\` shows through between\n * every row *and* column as a hairline divider, in both directions -- a container-level\n * \\`divide-y\\` (this control's previous approach, before the summary-item rework) only\n * ever divides one axis, which draws a confusing line between the two columns' cells of\n * the same visual row; a grid gap does not have that problem.\n */\n .matrix > foxy-internal-select-control {\n background-color: var(--lumo-contrast-5pct);\n padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px);\n }\n `,\n ];\n }\n\n /** Space-separated scope of the user creating or editing the invitation. */\n granterScope: string | null = null;\n\n /**\n * Set when the admin picks `Custom` explicitly. Needed because an empty scope parses to a\n * `null` preset, so without this the radio would snap back to nothing selected the moment\n * `Custom` was chosen but before any row was set.\n */\n private __customSelected = false;\n\n /**\n * Cached outcome of `__hasUnreachableGrant` from the most recently completed `renderControl()`\n * pass. Read by `updated()` below -- see its doc comment for why the lock needs to land on\n * `this.readonly` itself rather than staying a `renderControl()`-local variable.\n */\n private __isLocked = false;\n\n renderControl(): TemplateResult {\n const selection = parseScope(this.__scope);\n const grantable = getGrantable(this.granterScope ?? void 0);\n const currentPreset = this.__preset(selection);\n const presets: Preset[] = [];\n\n if (grantable.storeFullAccess) presets.push('store');\n if (canGrantReadPreset(grantable)) presets.push('read');\n presets.push('custom');\n\n // The invitation can already hold a preset this granter couldn't offer themselves --\n // e.g. a full-access admin created it, and a narrower admin is now editing it. Omitting\n // it would make an existing grant look like no grant at all, so it's still listed as an\n // option (the same treatment `__renderLevelControl` gives an out-of-reach row level) --\n // otherwise `summary-item`'s displayed value would fall back to its placeholder instead\n // of showing the invitation's actual preset. `custom` is always offered and `null`\n // selects nothing, so only `store` and `read` can end up here.\n const mismatchedPreset =\n currentPreset && !presets.includes(currentPreset) ? currentPreset : null;\n\n const renderedPresets: Preset[] = (['store', 'read', 'custom'] as const).filter(\n preset => presets.includes(preset) || preset === mismatchedPreset\n );\n\n // The invitation can hold a grant this granter cannot themselves re-grant (see\n // `__hasUnreachableGrant`, which treats a mismatched preset as grounds to lock on its\n // own). The API validates the *entire* submitted `scope` string\n // whenever it's dirty, not just the delta, so any edit here would re-serialize and\n // resubmit that out-of-reach value and the server would reject the whole save -- a\n // failure the admin cannot fix, because there is no way to *only* change the preset\n // without touching the rest. Locking the whole control instead means no edit, and\n // therefore no failing save, can be attempted. The out-of-reach value stays visible,\n // same as always -- only editability changes. Because a mismatched preset already forces\n // `isLocked` (and therefore `readonly`) below, no separate per-option disabling is needed\n // here either -- the same reasoning `__renderLevelControl` and `__renderResendSwitches`\n // already rely on for their own mismatches.\n const isLocked = this.__hasUnreachableGrant(selection, grantable, !!mismatchedPreset);\n\n // Read by `updated()` below -- see its doc comment for why the lock also needs to land on\n // the `readonly` *property* itself, not just this render pass's local variable.\n this.__isLocked = isLocked;\n\n const readonly = this.readonly || isLocked;\n const helperText = isLocked ? this.t('helper_text_locked') : this.helperText;\n\n const presetOptions: Option[] = renderedPresets.map(preset => ({\n label: `preset_${preset}`,\n value: preset,\n }));\n\n return html`\n <div class=\"grid gap-m\">\n <foxy-internal-summary-control infer=\"\" label=${this.label} helper-text=${helperText}>\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"\"\n label=${this.t('preset_label')}\n helper-text=\"\"\n data-preset=\"\"\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .options=${presetOptions}\n .getValue=${() => currentPreset ?? undefined}\n .setValue=${(newValue: unknown) => this.__selectPreset(newValue as Preset)}\n >\n </foxy-internal-select-control>\n </foxy-internal-summary-control>\n ${currentPreset === 'custom'\n ? html`\n <div class=\"matrix\">\n ${COLLECTIONS.map(collection =>\n this.__renderLevelControl(collection, selection, grantable, readonly)\n )}\n </div>\n ${this.__renderResendSwitches(selection, grantable, readonly)}\n `\n : ''}\n </div>\n `;\n }\n\n /**\n * Reflects a lock onto the real `readonly` property (in addition to whatever `updated()`\n * itself, e.g. `renderControl()`'s own `?readonly=` bindings, already did with the local\n * variable) once the initial render has committed.\n *\n * This exists because each row is now a nested `foxy-internal-select-control`.\n * `ConfigurableMixin` makes every such control infer its own `readonly` from the nearest\n * ancestor that has one (this control), by reading `this.readonly` directly during an async\n * walk (`InferrableMixin.inferFromElement`'s `key in element` check) -- not from whatever a\n * template attribute happened to bind on the row. That walk re-runs on every one of this\n * control's own updates (`InferrableMixin.updated()` calls `inferPropertiesInDescendants()`\n * unconditionally), so a row bound only via `?readonly=${this.readonly || isLocked}` in\n * `renderControl()` is overwritten back to whatever `this.readonly` was moments later --\n * confirmed empirically by a probe test, see this task's report. Setting `this.readonly`\n * itself is what the row's own inference actually reads, so this is not a workaround so much\n * as the property meaning what it says: locked really does mean the whole control, including\n * everything nested inside it, is readonly.\n *\n * Assigning inside `updated()` rather than `renderControl()`/`render()` matters too: mutating\n * a reactive property mid-render is what triggers lit's \"scheduled an update... during\n * update\" warning (and the `does not warn on a fresh empty-scope render` test would catch\n * it); `updated()` is the lifecycle hook lit itself documents for deriving follow-up state\n * from a completed render, and setting a property there does not warn.\n *\n * Never resets `this.readonly` back to `false` on its own -- the externally-imposed half\n * (e.g. the form's own `readonlycontrols` selector matching `scope`) is owned entirely by\n * `ConfigurableMixin`'s own inheritance, which keeps re-asserting its own value on every\n * update independently of this method.\n */\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n if (this.__isLocked && !this.readonly) this.readonly = true;\n }\n\n /**\n * `true` when the invitation already holds something this granter could not themselves\n * grant: the current preset isn't among the ones offered, a collection's current level\n * isn't grantable at that level, or a collection currently has a resend grant the granter\n * cannot extend. Reuses `canGrantLevel` / `canGrantResend` rather than reimplementing\n * grantability -- see `renderControl` for why this forces the whole control readonly.\n */\n private __hasUnreachableGrant(\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n hasMismatchedPreset: boolean\n ): boolean {\n if (hasMismatchedPreset) return true;\n\n const hasUnreachableLevel = COLLECTIONS.some(collection => {\n return !canGrantLevel(grantable, collection, selection.levels[collection] ?? 'none');\n });\n\n if (hasUnreachableLevel) return true;\n\n return selection.resend.some(collection => !canGrantResend(grantable, collection));\n }\n\n /**\n * Renders one collection's level picker as a self-contained `foxy-internal-select-control`\n * in `summary-item` layout: a native `<select>` with a real `<label for=\"select\">` (the\n * collection name, passed via `label`, replacing both the old sibling `foxy-i18n` and the\n * `aria-label` workaround that stood in for a proper accessible name before this control had\n * one) plus the current value shown as compact text. `data-collection` moves onto this\n * element directly -- there's no separate row wrapper left to carry it (see the control's\n * `styles` for why one output element per collection, not a wrapper `<div>` per row, is what\n * lets this control own its own two-column grid).\n */\n private __renderLevelControl(\n collection: string,\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n readonly: boolean\n ): TemplateResult {\n const allLevels: Level[] = ['none', 'read', 'full'];\n const currentLevel = selection.levels[collection] ?? 'none';\n\n // `stores_read` is what authorizes `GET /stores/{id}` and the `/stores` listing --\n // without it a user cannot load the store page or the store picker, so \"no store access\"\n // is not a real choice for this row going forward: this row's own select can only ever be\n // set to `read` or `full` from here on. This narrows what a user can newly *choose*, not\n // what a scope string already contains -- an invitation whose stores row has simply never\n // been touched (imported via the API, or edited only through a different row) still\n // parses `stores` as `none` and is written that way; see `mismatchedLevel` below for how\n // that value stays displayable without being treated as an unreachable grant.\n const offerable: Level[] = collection === 'stores' ? ['read', 'full'] : allLevels;\n const available = offerable.filter(level => canGrantLevel(grantable, collection, level));\n\n // The option list must be the grantable levels for this row, PLUS the row's current level\n // if it is not grantable/offerable. `vaadin-combo-box` reconciles its displayed value\n // against `.items` on every `.value`/`.items` change (verified directly, see the control's\n // test suite and this task's report), and the native `<select>` `summary-item` renders\n // behaves the same way for an unlisted `<option>` -- an out-of-reach current level not\n // present in `.options` would fail to display at all. `none` is always grantable (see\n // `canGrantLevel`), so for every collection except `stores` only `read` or `full` can end\n // up here as a mismatch -- but a legacy or API-created invitation can hold no `stores_*`\n // tokens at all, which parses to `none`, and `none` is no longer offerable for that one\n // row, so `none` itself can be the mismatch there.\n //\n // No per-option disabling is needed for a level the granter truly cannot re-grant:\n // `__hasUnreachableGrant` already forces the *entire* control readonly the instant any row\n // holds such a level, so that kind of mismatch can only ever be rendered while the whole\n // row control is already readonly. The `stores` row's own `none` mismatch is different --\n // `canGrantLevel` returns `true` unconditionally for `'none'` (see `invitation-scope.ts`),\n // so it is a *legal* grant the granter could re-issue, not an unreachable one. It does not\n // trip `__hasUnreachableGrant`, and is rendered editable while the rest of the control\n // stays unlocked (pinned by this control's own test suite: \"does not lock the control\n // merely because the stores row is at its mismatched-but-grantable none\"). Either way, the\n // out-of-reach value is simply the control's value.\n const mismatchedLevel = available.includes(currentLevel) ? null : currentLevel;\n\n // Filtered from `allLevels`, not the narrowed `offerable` list: for the `stores` row,\n // `none` was removed from `offerable` above, but an invitation with no `stores_*` tokens\n // still parses its current level as `none`. Filtering from `offerable` here would drop\n // `none` from the rendered options even when it's `mismatchedLevel`, leaving the select's\n // value absent from its own option list -- the same \"current value must stay a real\n // option\" rule as the `mismatchedLevel` fallback right above, just applied one filter\n // earlier where a narrower source list can undo it.\n const renderedLevels = allLevels.filter(\n level => available.includes(level) || level === mismatchedLevel\n );\n\n const options: Option[] = renderedLevels.map(level => ({\n label: `level_${level}`,\n value: level,\n }));\n\n return html`\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"\"\n label=${this.t(`scopes.${collection}`)}\n helper-text=\"\"\n data-collection=${collection}\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .options=${options}\n .getValue=${() => currentLevel}\n .setValue=${(newValue: unknown) => {\n // The native `<select>` `summary-item` renders always has a real selection (its\n // first, disabled placeholder `<option>` aside) once a value is set, so there is no\n // \"clear\" affordance to coerce here the way the old vaadin-combo-box row needed --\n // kept anyway as the same defensive floor: there is no \"no level\" state for a row,\n // and this must never let an empty/undefined token reach the serialized scope.\n this.__setLevel(collection, ((newValue as string) || 'none') as Level);\n }}\n >\n </foxy-internal-select-control>\n `;\n }\n\n /**\n * Renders the three resendable collections' resend grants as `foxy-internal-switch-control`s,\n * one per line, in their own `foxy-internal-summary-control` -- not folded into the level\n * grid above. Resend is a secondary, independent axis (a collection's level and its resend\n * grant are unrelated tokens -- see `parseScope`/`serializeScope`), covers only 3 of the 20\n * collections, and doesn't need the level grid's two-column treatment; keeping it as its own\n * section also means the grid's CSS (sized for 20 short rows) never has to accommodate a\n * structurally different kind of row. Renders nothing at all if the granter can't grant (and\n * the invitation doesn't already hold) any resend permission, rather than an empty section.\n */\n private __renderResendSwitches(\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n readonly: boolean\n ): TemplateResult | string {\n const switches = RESENDABLE.map(collection => {\n const hasResend = selection.resend.includes(collection);\n const canResend = canGrantResend(grantable, collection);\n\n // Mirrors the level mismatch in `__renderLevelControl`: the invitation can already carry\n // a resend grant this granter can no longer extend themselves. Unlike the level mismatch,\n // this needs no *separate* `disabled` condition below -- `__hasUnreachableGrant` already\n // treats any resend mismatch as grounds to lock the *entire* control (see its own return\n // statement), so `mismatchedResend` and this control's own `readonly` are never true/false\n // independently of each other; adding a redundant `?disabled=` term here would only be\n // exercising `foxy-internal-switch-control`'s `disabled` -- a `ConfigurableMixin`-inferred\n // property subject to the exact same ancestor-inference-can-overwrite-a-template-binding\n // risk documented on this control's own `updated()`, for a case that can't actually occur.\n const mismatchedResend = hasResend && !canResend;\n\n return { collection, hasResend, mismatchedResend, show: canResend || mismatchedResend };\n }).filter(entry => entry.show);\n\n if (!switches.length) return '';\n\n return html`\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${switches.map(\n ({ collection, hasResend }) => html`\n <foxy-internal-switch-control\n infer=\"\"\n label=${`${this.t('resend')} ${this.t(`scopes.${collection}`).toLowerCase()}`}\n helper-text=\"\"\n data-resend=${collection}\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .getValue=${() => hasResend}\n .setValue=${(newValue: unknown) => this.__setResend(collection, !!newValue)}\n >\n </foxy-internal-switch-control>\n `\n )}\n </foxy-internal-summary-control>\n `;\n }\n\n private __setLevel(collection: string, level: Level): void {\n // Touching a row is proof the admin is actively editing in custom mode. Without this, an\n // edit that happens to make the selection match another preset (e.g. the last collection\n // reaching `read`) would make `__preset` fall back to `parseScope`'s classification and the\n // matrix would vanish out from under the admin mid-edit.\n this.__customSelected = true;\n\n const selection = parseScope(this.__scope);\n selection.levels[collection] = level;\n this._value = serializeScope({ ...selection, preset: 'custom' });\n }\n\n private __setResend(collection: string, checked: boolean): void {\n this.__customSelected = true;\n\n const selection = parseScope(this.__scope);\n\n const resend = checked\n ? [...selection.resend, collection]\n : selection.resend.filter(entry => entry !== collection);\n\n this._value = serializeScope({ ...selection, preset: 'custom', resend });\n }\n\n /**\n * The scope currently in the form. Undefined before the first edit on a new invitation.\n * An existing invitation saved without a scope grants full store access in the API, so it\n * reads as the wildcard here instead of as \"nothing chosen\".\n */\n private get __scope(): string | undefined {\n const scope = (this._value as string | undefined) ?? void 0;\n if (!scope?.trim() && this.nucleon?.data) return 'store_full_access';\n return scope;\n }\n\n private __preset(selection: Selection): Preset | null {\n if (this.__customSelected) return 'custom';\n return selection.preset;\n }\n\n private __selectPreset(preset: Preset): void {\n this.__customSelected = preset === 'custom';\n\n // Choosing Custom keeps whatever is already in the form, so the matrix opens on the\n // current grant rather than wiping it. The wildcard has no per-row levels, so it is\n // expanded into what it grants -- every collection at Full and every resend. Keeping\n // `store_full_access` behind rows that all read None would save a full-access invitation.\n if (preset === 'custom') {\n const selection = parseScope(this.__scope);\n if (selection.preset !== 'store') return;\n\n COLLECTIONS.forEach(collection => (selection.levels[collection] = 'full'));\n this._value = serializeScope({ ...selection, preset: 'custom', resend: [...RESENDABLE] });\n return;\n }\n\n if (preset === 'store') {\n this._value = 'store_full_access';\n } else {\n const selection = parseScope('');\n COLLECTIONS.forEach(collection => (selection.levels[collection] = 'read'));\n this._value = serializeScope(selection);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalUserInvitationFormScopeControl.js","sourceRoot":"","sources":["../../../../../../src/elements/public/UserInvitationForm/internal/InternalUserInvitationFormScopeControl/InternalUserInvitationFormScopeControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,gFAA6E;AAC/G,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,wDAAqD;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,GACf,iDAA8C;AAI/C;;;;;;;;;GASG;AACH,MAAM,OAAO,sCAAuC,SAAQ,uBAAuB;IAAnF;;QAsEE,4EAA4E;QAC5E,iBAAY,GAAkB,IAAI,CAAC;QAEnC;;;;WAIG;QACK,qBAAgB,GAAG,KAAK,CAAC;QAEjC;;;;WAIG;QACK,eAAU,GAAG,KAAK,CAAC;IAuX7B,CAAC;IA3cC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,YAAY,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE;YAC5C,gBAAgB,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SACvC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,GAAG,KAAK,CAAC,MAAM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AAC,EAAE,GAAG,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;YACjE,OAAO;SACR;QAED,IAAI,MAAM,KAAK,OAAO,EAAE;YACtB,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC;SACnC;aAAM;YACL,MAAM,SAAS,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;YACjC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAC3E,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;SACzC;IACH,CAAC;CACF","sourcesContent":["import type { CSSResultArray, PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { Option } from '../../../../internal/InternalSelectControl/types';\nimport type { Level, Selection } from '../../../../../utils/invitation-scope';\n\nimport { InternalEditableControl } from '../../../../internal/InternalEditableControl/InternalEditableControl';\nimport { COLLECTIONS, RESENDABLE } from '../../../../../utils/group-invitation-scopes';\nimport { BooleanSelector } from '@foxy.io/sdk/core';\nimport { css } from 'lit-element';\nimport { html } from 'lit-html';\n\nimport {\n canGrantLevel,\n canGrantReadPreset,\n canGrantResend,\n getGrantable,\n parseScope,\n serializeScope,\n} from '../../../../../utils/invitation-scope';\n\ntype Preset = 'store' | 'read' | 'custom';\n\n/**\n * Lets an admin choose which scopes an invitation grants, offering only what the granting\n * user already holds.\n *\n * Bound to the invitation's `scope` string through `infer=\"scope\"`. The server is the real\n * enforcement boundary; this control exists so the UI\n * never offers a grant that would be rejected.\n *\n * @element foxy-internal-user-invitation-form-scope-control\n */\nexport class InternalUserInvitationFormScopeControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n granterScope: { attribute: 'granter-scope' },\n __customSelected: { attribute: false },\n };\n }\n\n static get styles(): CSSResultArray {\n return [\n ...super.styles,\n css`\n /*\n * \\`foxy-internal-summary-control\\` puts \\`::slotted(*) { min-width: 100% }\\` on\n * whatever it slots, and (outside \\`layout=\"section\"\\`) a background/padding on each\n * slotted element too -- both aimed at a vertical list of full-width summary-items, and\n * both outside this control's reach: they're declared against the *slotted* elements\n * from the summary control's own shadow tree, not against anything inside this one, so\n * there is no selector this control's own \\`static styles\\` could write that would stop\n * a slotted element from being full-width, and the grid that would need a second\n * \\`grid-template-columns\\` track lives inside the summary control's own shadow root --\n * not reachable at all from here (confirmed: a \\`::slotted(*)\\` rule only ever targets\n * the slotted elements themselves, never the host's own internal structure around the\n * \\`<slot>\\`). So overriding a rule of ours against the slotted elements, per CSS\n * Scoping's normal-declarations-in-the-tree-the-element-lives-in-beat-::slotted()-rule\n * precedence, can only ever affect how each *individual* slotted box is sized -- it\n * cannot make the summary control itself lay two of them out side by side, because nothing\n * this control writes can reach that summary control's own internal grid container.\n *\n * So there is exactly one slotted child here: \\`.matrix\\`, a wrapper \\`<div>\\` (see\n * \\`renderControl\\`) that lays its own 20 real children out in a grid this control fully\n * owns. \\`layout=\"section\"\\` on the summary control (see \\`renderControl\\`) opts out of its\n * background/padding-on-slotted-child rule, since that would otherwise tint the *whole*\n * wrapper as one block; this control re-creates the summary-item tile look itself, on\n * each *individual* row, below.\n */\n .matrix {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 1px;\n border-radius: var(--lumo-border-radius);\n overflow: hidden;\n }\n\n @media all and (min-width: 640px) {\n .matrix {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n }\n }\n\n /*\n * Each row is one \\`foxy-internal-select-control[layout=\"summary-item\"]\\`, a single\n * self-contained element (see \\`__renderLevelControl\\`) -- no more per-row wrapper,\n * sibling label, or separate checkbox. Its own background here (rather than\n * \\`::slotted(*)\\`'s, opted out of above) is what recreates the individual-tile look;\n * the 1px \\`.matrix\\` gap on top of \\`var(--lumo-contrast-10pct)\\` shows through between\n * every row *and* column as a hairline divider, in both directions -- a container-level\n * \\`divide-y\\` (this control's previous approach, before the summary-item rework) only\n * ever divides one axis, which draws a confusing line between the two columns' cells of\n * the same visual row; a grid gap does not have that problem.\n */\n .matrix > foxy-internal-select-control {\n background-color: var(--lumo-contrast-5pct);\n padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px);\n }\n `,\n ];\n }\n\n /** Space-separated scope of the user creating or editing the invitation. */\n granterScope: string | null = null;\n\n /**\n * Set when the admin picks `Custom` explicitly. Needed because an empty scope parses to a\n * `null` preset, so without this the radio would snap back to nothing selected the moment\n * `Custom` was chosen but before any row was set.\n */\n private __customSelected = false;\n\n /**\n * Cached outcome of `__hasUnreachableGrant` from the most recently completed `renderControl()`\n * pass. Read by `updated()` below -- see its doc comment for why the lock needs to land on\n * `this.readonly` itself rather than staying a `renderControl()`-local variable.\n */\n private __isLocked = false;\n\n renderControl(): TemplateResult {\n const selection = parseScope(this.__scope);\n const grantable = getGrantable(this.granterScope ?? void 0);\n const currentPreset = this.__preset(selection);\n const presets: Preset[] = [];\n\n if (grantable.storeFullAccess) presets.push('store');\n if (canGrantReadPreset(grantable)) presets.push('read');\n presets.push('custom');\n\n // The invitation can already hold a preset this granter couldn't offer themselves --\n // e.g. a full-access admin created it, and a narrower admin is now editing it. Omitting\n // it would make an existing grant look like no grant at all, so it's still listed as an\n // option (the same treatment `__renderLevelControl` gives an out-of-reach row level) --\n // otherwise `summary-item`'s displayed value would fall back to its placeholder instead\n // of showing the invitation's actual preset. `custom` is always offered and `null`\n // selects nothing, so only `store` and `read` can end up here.\n const mismatchedPreset =\n currentPreset && !presets.includes(currentPreset) ? currentPreset : null;\n\n const renderedPresets: Preset[] = (['store', 'read', 'custom'] as const).filter(\n preset => presets.includes(preset) || preset === mismatchedPreset\n );\n\n // The invitation can hold a grant this granter cannot themselves re-grant (see\n // `__hasUnreachableGrant`, which treats a mismatched preset as grounds to lock on its\n // own). The API validates the *entire* submitted `scope` string\n // whenever it's dirty, not just the delta, so any edit here would re-serialize and\n // resubmit that out-of-reach value and the server would reject the whole save -- a\n // failure the admin cannot fix, because there is no way to *only* change the preset\n // without touching the rest. Locking the whole control instead means no edit, and\n // therefore no failing save, can be attempted. The out-of-reach value stays visible,\n // same as always -- only editability changes. Because a mismatched preset already forces\n // `isLocked` (and therefore `readonly`) below, no separate per-option disabling is needed\n // here either -- the same reasoning `__renderLevelControl` and `__renderResendSwitches`\n // already rely on for their own mismatches.\n const isLocked = this.__hasUnreachableGrant(selection, grantable, !!mismatchedPreset);\n\n // Read by `updated()` below -- see its doc comment for why the lock also needs to land on\n // the `readonly` *property* itself, not just this render pass's local variable.\n this.__isLocked = isLocked;\n\n const readonly = this.readonly || isLocked;\n const helperText = isLocked ? this.t('helper_text_locked') : this.helperText;\n\n const presetOptions: Option[] = renderedPresets.map(preset => ({\n label: `preset_${preset}`,\n value: preset,\n }));\n\n return html`\n <div class=\"grid gap-m\">\n <foxy-internal-summary-control infer=\"\" label=${this.label} helper-text=${helperText}>\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"\"\n label=${this.t('preset_label')}\n helper-text=\"\"\n data-preset=\"\"\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .options=${presetOptions}\n .getValue=${() => currentPreset ?? undefined}\n .setValue=${(newValue: unknown) => this.__selectPreset(newValue as Preset)}\n >\n </foxy-internal-select-control>\n </foxy-internal-summary-control>\n ${currentPreset === 'custom'\n ? html`\n <div class=\"matrix\">\n ${COLLECTIONS.map(collection =>\n this.__renderLevelControl(collection, selection, grantable, readonly)\n )}\n </div>\n ${this.__renderResendSwitches(selection, grantable, readonly)}\n `\n : ''}\n </div>\n `;\n }\n\n /**\n * Reflects a lock onto the real `readonly` property (in addition to whatever `updated()`\n * itself, e.g. `renderControl()`'s own `?readonly=` bindings, already did with the local\n * variable) once the initial render has committed.\n *\n * This exists because each row is now a nested `foxy-internal-select-control`.\n * `ConfigurableMixin` makes every such control infer its own `readonly` from the nearest\n * ancestor that has one (this control), by reading `this.readonly` directly during an async\n * walk (`InferrableMixin.inferFromElement`'s `key in element` check) -- not from whatever a\n * template attribute happened to bind on the row. That walk re-runs on every one of this\n * control's own updates (`InferrableMixin.updated()` calls `inferPropertiesInDescendants()`\n * unconditionally), so a row bound only via `?readonly=${this.readonly || isLocked}` in\n * `renderControl()` is overwritten back to whatever `this.readonly` was moments later --\n * confirmed empirically by a probe test, see this task's report. Setting `this.readonly`\n * itself is what the row's own inference actually reads, so this is not a workaround so much\n * as the property meaning what it says: locked really does mean the whole control, including\n * everything nested inside it, is readonly.\n *\n * Assigning inside `updated()` rather than `renderControl()`/`render()` matters too: mutating\n * a reactive property mid-render is what triggers lit's \"scheduled an update... during\n * update\" warning (and the `does not warn on a fresh empty-scope render` test would catch\n * it); `updated()` is the lifecycle hook lit itself documents for deriving follow-up state\n * from a completed render, and setting a property there does not warn.\n *\n * Never resets `this.readonly` back to `false` on its own -- the externally-imposed half\n * (e.g. the form's own `readonlycontrols` selector matching `scope`) is owned entirely by\n * `ConfigurableMixin`'s own inheritance, which keeps re-asserting its own value on every\n * update independently of this method.\n */\n updated(changes: Map<keyof this, unknown>): void {\n super.updated(changes);\n if (this.__isLocked && !this.readonly) this.readonly = true;\n }\n\n // A resend switch at Full is inferred as `included-resend`, so it can be readonly on its own:\n // a `?readonly=` binding on it would be overwritten by inference, as `updated()` describes.\n get readonlySelector(): BooleanSelector {\n return new BooleanSelector(`${super.readonlySelector.toString()} included-resend`.trim());\n }\n\n /**\n * `true` when the invitation already holds something this granter could not themselves\n * grant: the current preset isn't among the ones offered, a collection's current level\n * isn't grantable at that level, or a collection currently has a resend grant the granter\n * cannot extend. Reuses `canGrantLevel` / `canGrantResend` rather than reimplementing\n * grantability -- see `renderControl` for why this forces the whole control readonly.\n */\n private __hasUnreachableGrant(\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n hasMismatchedPreset: boolean\n ): boolean {\n if (hasMismatchedPreset) return true;\n\n const hasUnreachableLevel = COLLECTIONS.some(collection => {\n return !canGrantLevel(grantable, collection, selection.levels[collection] ?? 'none');\n });\n\n if (hasUnreachableLevel) return true;\n\n return selection.resend.some(collection => !canGrantResend(grantable, collection));\n }\n\n /**\n * Renders one collection's level picker as a self-contained `foxy-internal-select-control`\n * in `summary-item` layout: a native `<select>` with a real `<label for=\"select\">` (the\n * collection name, passed via `label`, replacing both the old sibling `foxy-i18n` and the\n * `aria-label` workaround that stood in for a proper accessible name before this control had\n * one) plus the current value shown as compact text. `data-collection` moves onto this\n * element directly -- there's no separate row wrapper left to carry it (see the control's\n * `styles` for why one output element per collection, not a wrapper `<div>` per row, is what\n * lets this control own its own two-column grid).\n */\n private __renderLevelControl(\n collection: string,\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n readonly: boolean\n ): TemplateResult {\n const allLevels: Level[] = ['none', 'read', 'full'];\n const currentLevel = selection.levels[collection] ?? 'none';\n\n // `stores_read` is what authorizes `GET /stores/{id}` and the `/stores` listing --\n // without it a user cannot load the store page or the store picker, so \"no store access\"\n // is not a real choice for this row going forward: this row's own select can only ever be\n // set to `read` or `full` from here on. This narrows what a user can newly *choose*, not\n // what a scope string already contains -- an invitation whose stores row has simply never\n // been touched (imported via the API, or edited only through a different row) still\n // parses `stores` as `none` and is written that way; see `mismatchedLevel` below for how\n // that value stays displayable without being treated as an unreachable grant.\n const offerable: Level[] = collection === 'stores' ? ['read', 'full'] : allLevels;\n const available = offerable.filter(level => canGrantLevel(grantable, collection, level));\n\n // The option list must be the grantable levels for this row, PLUS the row's current level\n // if it is not grantable/offerable. `vaadin-combo-box` reconciles its displayed value\n // against `.items` on every `.value`/`.items` change (verified directly, see the control's\n // test suite and this task's report), and the native `<select>` `summary-item` renders\n // behaves the same way for an unlisted `<option>` -- an out-of-reach current level not\n // present in `.options` would fail to display at all. `none` is always grantable (see\n // `canGrantLevel`), so for every collection except `stores` only `read` or `full` can end\n // up here as a mismatch -- but a legacy or API-created invitation can hold no `stores_*`\n // tokens at all, which parses to `none`, and `none` is no longer offerable for that one\n // row, so `none` itself can be the mismatch there.\n //\n // No per-option disabling is needed for a level the granter truly cannot re-grant:\n // `__hasUnreachableGrant` already forces the *entire* control readonly the instant any row\n // holds such a level, so that kind of mismatch can only ever be rendered while the whole\n // row control is already readonly. The `stores` row's own `none` mismatch is different --\n // `canGrantLevel` returns `true` unconditionally for `'none'` (see `invitation-scope.ts`),\n // so it is a *legal* grant the granter could re-issue, not an unreachable one. It does not\n // trip `__hasUnreachableGrant`, and is rendered editable while the rest of the control\n // stays unlocked (pinned by this control's own test suite: \"does not lock the control\n // merely because the stores row is at its mismatched-but-grantable none\"). Either way, the\n // out-of-reach value is simply the control's value.\n const mismatchedLevel = available.includes(currentLevel) ? null : currentLevel;\n\n // Filtered from `allLevels`, not the narrowed `offerable` list: for the `stores` row,\n // `none` was removed from `offerable` above, but an invitation with no `stores_*` tokens\n // still parses its current level as `none`. Filtering from `offerable` here would drop\n // `none` from the rendered options even when it's `mismatchedLevel`, leaving the select's\n // value absent from its own option list -- the same \"current value must stay a real\n // option\" rule as the `mismatchedLevel` fallback right above, just applied one filter\n // earlier where a narrower source list can undo it.\n const renderedLevels = allLevels.filter(\n level => available.includes(level) || level === mismatchedLevel\n );\n\n const options: Option[] = renderedLevels.map(level => ({\n label: `level_${level}`,\n value: level,\n }));\n\n return html`\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"\"\n label=${this.t(`scopes.${collection}`)}\n helper-text=\"\"\n data-collection=${collection}\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .options=${options}\n .getValue=${() => currentLevel}\n .setValue=${(newValue: unknown) => {\n // The native `<select>` `summary-item` renders always has a real selection (its\n // first, disabled placeholder `<option>` aside) once a value is set, so there is no\n // \"clear\" affordance to coerce here the way the old vaadin-combo-box row needed --\n // kept anyway as the same defensive floor: there is no \"no level\" state for a row,\n // and this must never let an empty/undefined token reach the serialized scope.\n this.__setLevel(collection, ((newValue as string) || 'none') as Level);\n }}\n >\n </foxy-internal-select-control>\n `;\n }\n\n /**\n * Renders the three resendable collections' resend grants as `foxy-internal-switch-control`s,\n * one per line, in their own `foxy-internal-summary-control` -- not folded into the level\n * grid above. Resend is a secondary axis (below Full, a collection's level and its resend\n * grant are unrelated tokens -- see `parseScope`/`serializeScope`; Full includes resend, so the\n * switch then shows as on and readonly), covers only 3 of the 20\n * collections, and doesn't need the level grid's two-column treatment; keeping it as its own\n * section also means the grid's CSS (sized for 20 short rows) never has to accommodate a\n * structurally different kind of row. Renders nothing at all if the granter can't grant (and\n * the invitation doesn't already hold) any resend permission, rather than an empty section.\n */\n private __renderResendSwitches(\n selection: Selection,\n grantable: ReturnType<typeof getGrantable>,\n readonly: boolean\n ): TemplateResult | string {\n const switches = RESENDABLE.map(collection => {\n const included = selection.levels[collection] === 'full';\n const hasResend = selection.resend.includes(collection);\n const canResend = canGrantResend(grantable, collection);\n\n // Mirrors the level mismatch in `__renderLevelControl`: the invitation can already carry\n // a resend grant this granter can no longer extend themselves. Unlike the level mismatch,\n // this needs no *separate* `disabled` condition below -- `__hasUnreachableGrant` already\n // treats any resend mismatch as grounds to lock the *entire* control (see its own return\n // statement), so `mismatchedResend` and this control's own `readonly` are never true/false\n // independently of each other; adding a redundant `?disabled=` term here would only be\n // exercising `foxy-internal-switch-control`'s `disabled` -- a `ConfigurableMixin`-inferred\n // property subject to the exact same ancestor-inference-can-overwrite-a-template-binding\n // risk documented on this control's own `updated()`, for a case that can't actually occur.\n const mismatchedResend = hasResend && !canResend;\n\n return {\n collection,\n included,\n hasResend: hasResend || included,\n mismatchedResend,\n show: canResend || mismatchedResend || included,\n };\n }).filter(entry => entry.show);\n\n if (!switches.length) return '';\n\n return html`\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${switches.map(\n ({ collection, included, hasResend }) => html`\n <foxy-internal-switch-control\n infer=${included ? 'included-resend' : ''}\n label=${`${this.t('resend')} ${this.t(`scopes.${collection}`).toLowerCase()}`}\n helper-text=\"\"\n data-resend=${collection}\n ?disabled=${this.disabled}\n ?readonly=${readonly}\n .getValue=${() => hasResend}\n .setValue=${(newValue: unknown) => this.__setResend(collection, !!newValue)}\n >\n </foxy-internal-switch-control>\n `\n )}\n </foxy-internal-summary-control>\n `;\n }\n\n private __setLevel(collection: string, level: Level): void {\n // Touching a row is proof the admin is actively editing in custom mode. Without this, an\n // edit that happens to make the selection match another preset (e.g. the last collection\n // reaching `read`) would make `__preset` fall back to `parseScope`'s classification and the\n // matrix would vanish out from under the admin mid-edit.\n this.__customSelected = true;\n\n const selection = parseScope(this.__scope);\n const crossesFull = level === 'full' || selection.levels[collection] === 'full';\n selection.levels[collection] = level;\n\n // Full includes resend, so the switch shows the same at Full with or without the token.\n // Dropping it here means leaving Full always clears resend, whichever way it was stored.\n const resend = crossesFull\n ? selection.resend.filter(entry => entry !== collection)\n : selection.resend;\n\n this._value = serializeScope({ ...selection, preset: 'custom', resend });\n }\n\n private __setResend(collection: string, checked: boolean): void {\n this.__customSelected = true;\n\n const selection = parseScope(this.__scope);\n\n const resend = checked\n ? [...selection.resend, collection]\n : selection.resend.filter(entry => entry !== collection);\n\n this._value = serializeScope({ ...selection, preset: 'custom', resend });\n }\n\n /**\n * The scope currently in the form. Undefined before the first edit on a new invitation.\n * An existing invitation saved without a scope grants full store access in the API, so it\n * reads as the wildcard here instead of as \"nothing chosen\".\n */\n private get __scope(): string | undefined {\n const scope = (this._value as string | undefined) ?? void 0;\n if (!scope?.trim() && this.nucleon?.data) return 'store_full_access';\n return scope;\n }\n\n private __preset(selection: Selection): Preset | null {\n if (this.__customSelected) return 'custom';\n return selection.preset;\n }\n\n private __selectPreset(preset: Preset): void {\n this.__customSelected = preset === 'custom';\n\n // Choosing Custom keeps whatever is already in the form, so the matrix opens on the\n // current grant rather than wiping it. The wildcard has no per-row levels, so it is\n // expanded into what it grants -- every collection at Full, which includes resend. Keeping\n // `store_full_access` behind rows that all read None would save a full-access invitation.\n if (preset === 'custom') {\n const selection = parseScope(this.__scope);\n if (selection.preset !== 'store') return;\n\n COLLECTIONS.forEach(collection => (selection.levels[collection] = 'full'));\n this._value = serializeScope({ ...selection, preset: 'custom' });\n return;\n }\n\n if (preset === 'store') {\n this._value = 'store_full_access';\n } else {\n const selection = parseScope('');\n COLLECTIONS.forEach(collection => (selection.levels[collection] = 'read'));\n this._value = serializeScope(selection);\n }\n }\n}\n"]}
|
|
@@ -26,7 +26,7 @@ export declare type ScopeGroups = {
|
|
|
26
26
|
full: string[];
|
|
27
27
|
/** Collections the user can read but not write. */
|
|
28
28
|
read: string[];
|
|
29
|
-
/** Collections the user can resend.
|
|
29
|
+
/** Collections the user can resend without full access. Full access includes resend. */
|
|
30
30
|
resend: string[];
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
@@ -57,12 +57,14 @@ export function groupInvitationScopes(scope) {
|
|
|
57
57
|
COLLECTIONS.forEach(collection => {
|
|
58
58
|
// A write scope satisfies a read check in the API, so write wins and the collection
|
|
59
59
|
// is never listed as read-only as well.
|
|
60
|
-
|
|
60
|
+
const hasWrite = tokens.has(`${collection}_write`);
|
|
61
|
+
if (hasWrite)
|
|
61
62
|
full.push(collection);
|
|
62
63
|
else if (tokens.has(`${collection}_read`))
|
|
63
64
|
read.push(collection);
|
|
65
|
+
// Write includes resend in the API, so a full collection is not listed again as resend.
|
|
64
66
|
const isResendable = RESENDABLE.includes(collection);
|
|
65
|
-
if (isResendable && tokens.has(`${collection}_resend`))
|
|
67
|
+
if (isResendable && !hasWrite && tokens.has(`${collection}_resend`))
|
|
66
68
|
resend.push(collection);
|
|
67
69
|
});
|
|
68
70
|
return { storeFullAccess: false, full, read, resend };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-invitation-scopes.js","sourceRoot":"","sources":["../../src/utils/group-invitation-scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO;IACP,SAAS;IACT,WAAW;IACX,0BAA0B;IAC1B,eAAe;IACf,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,kBAAkB;IAClB,WAAW;IACX,uBAAuB;IACvB,mBAAmB;IACnB,QAAQ;IACR,eAAe;IACf,uBAAuB;IACvB,OAAO;IACP,WAAW;IACX,cAAc;IACd,kBAAkB;IAClB,UAAU;CACF,CAAC;AAEX,oEAAoE;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,cAAc,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAazE;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAgC;IACpE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAErF,IAAI,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE;QACnC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;KAClE;IAED,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC/B,oFAAoF;QACpF,wCAAwC;QACxC,
|
|
1
|
+
{"version":3,"file":"group-invitation-scopes.js","sourceRoot":"","sources":["../../src/utils/group-invitation-scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO;IACP,SAAS;IACT,WAAW;IACX,0BAA0B;IAC1B,eAAe;IACf,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,kBAAkB;IAClB,WAAW;IACX,uBAAuB;IACvB,mBAAmB;IACnB,QAAQ;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C,GAAG,CAAC,GAAG,UAAU,SAAS,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACxD,CAAC","sourcesContent":["/**\n * Collections an invitation may grant, taken from the API's list of invitation collections minus\n * the two that are not meaningful choices.\n *\n * This list is duplicated from the API. A collection added there will be silently omitted\n * here until it is added to this array AND given a `scopes.<token>` label in every consuming\n * namespace (`user-invitation-card`, `user-invitation-form`). Rendering an unlabelled raw\n * token among humanized names looks broken, so omission is the deliberate failure mode.\n *\n * Two of the API's 22 collections are excluded on purpose -- do not \"fix\" the omission:\n *\n * - `clients`: a separate top-level resource that the Foxy admin does not manage.\n * Sign-in never issues `clients_read`/`clients_write`, so granting them would have\n * no effect.\n * - `users`: the API treats `user_full_access` as `users_read users_write`,\n * and every admin sign-in requests `user_full_access`, so a user's access here never\n * depends on their invitation. A toggle would be inert rather than merely redundant.\n */\nexport const COLLECTIONS = [\n 'carts',\n 'coupons',\n 'customers',\n 'customer_portal_settings',\n 'downloadables',\n 'gift_cards',\n 'integrations',\n 'item_categories',\n 'payment_settings',\n 'reporting',\n 'shipping_integrations',\n 'shipping_settings',\n 'stores',\n 'subscriptions',\n 'subscription_settings',\n 'taxes',\n 'templates',\n 'transactions',\n 'user_invitations',\n 'webhooks',\n] as const;\n\n/** Collections that additionally support a `_resend` permission. */\nexport const RESENDABLE = ['transactions', 'webhooks', 'taxes'] as const;\n\nexport type ScopeGroups = {\n /** `store_full_access` was present. All other tokens are ignored and the arrays are empty. */\n storeFullAccess: boolean;\n /** Collections the user can read and write. A `_write` scope implies read, per the API. */\n full: string[];\n /** Collections the user can read but not write. */\n read: string[];\n /** Collections the user can resend without full access. Full access includes resend. */\n resend: string[];\n};\n\n/**\n * Groups an invitation's space-separated `scope` string by permission level.\n *\n * Returns collection tokens rather than display labels: labels are localized, and sorting\n * by them belongs in the element that has a translation function.\n */\nexport function groupInvitationScopes(scope: string | null | undefined): ScopeGroups {\n const tokens = new Set((scope ?? '').split(/\\s+/).filter(token => token.length > 0));\n\n if (tokens.has('store_full_access')) {\n return { storeFullAccess: true, full: [], read: [], resend: [] };\n }\n\n const full: string[] = [];\n const read: string[] = [];\n const resend: string[] = [];\n\n COLLECTIONS.forEach(collection => {\n // A write scope satisfies a read check in the API, so write wins and the collection\n // is never listed as read-only as well.\n const hasWrite = tokens.has(`${collection}_write`);\n if (hasWrite) full.push(collection);\n else if (tokens.has(`${collection}_read`)) read.push(collection);\n\n // Write includes resend in the API, so a full collection is not listed again as resend.\n const isResendable = (RESENDABLE as readonly string[]).includes(collection);\n if (isResendable && !hasWrite && tokens.has(`${collection}_resend`)) resend.push(collection);\n });\n\n return { storeFullAccess: false, full, read, resend };\n}\n"]}
|
|
@@ -5,7 +5,7 @@ export declare type Selection = {
|
|
|
5
5
|
preset: 'store' | 'read' | 'custom' | null;
|
|
6
6
|
/** Level per collection, keyed by the tokens in `COLLECTIONS`. Always fully populated. */
|
|
7
7
|
levels: Record<string, Level>;
|
|
8
|
-
/** Collections with
|
|
8
|
+
/** Collections with their own `_resend` token. The API includes resend in `full`. */
|
|
9
9
|
resend: string[];
|
|
10
10
|
/**
|
|
11
11
|
* Tokens this UI does not model, carried through untouched. `client_full_access` and
|