@foxy.io/elements 1.60.2 → 1.60.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import"./shared-0996f4d0.js";import"./foxy-nucleon-element.js";import"./shared-c066b7fd.js";import{_ as e}from"./shared-8f9014ff.js";import{l as t,u as a}from"./shared-cf613436.js";import{c as s}from"./shared-87e17c02.js";import{C as r}from"./shared-222b23bb.js";import{a as o}from"./shared-5b8c7250.js";import{I as n}from"./shared-56278a3c.js";import{i as d}from"./shared-53e42a77.js";import{h as i}from"./shared-ba5c42c7.js";import"./foxy-spinner.js";import"./shared-c59277a4.js";import"./shared-c3d6bcc0.js";import"./shared-f410644a.js";import"./shared-cf1965cb.js";import"./shared-930e68b7.js";import"./shared-c85c1864.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-4e709717.js";let l,c,p,y,u=e=>e;const h=r(o(n,"payment-card"));class _ extends h{constructor(){super(...arguments),this.hostedPaymentGatewaysHelper=null,this.paymentGatewaysHelper=null,this.__hostedPaymentGatewaysLoaderId="hostedPaymentGatewaysLoader",this.__paymentGatewaysLoaderId="paymentGatewaysLoader",this.__transactionLoaderId="transactionLoader",this.__storeLoaderId="storeLoader"}static get properties(){return e(e({},super.properties),{},{hostedPaymentGatewaysHelper:{attribute:"hosted-payment-gateways-helper"},paymentGatewaysHelper:{attribute:"payment-gateways-helper"}})}renderBody(){var e,s,r,o,n,h,_,m,f;const v=this.data,x=`${null!==(e=null==v?void 0:v.amount)&&void 0!==e?e:""} ${this.__currencyCode}`,$={currencyDisplay:this.__currencyDisplay,amount:x},w=null!==(r=null===(s=this.data)||void 0===s?void 0:s.fraud_protection_score)&&void 0!==r?r:0,b=w>0?"text-error":"text-success",j=w>0?"bg-error-10":"bg-success-10",L=(null!==(o=null==v?void 0:v.cc_type)&&void 0!==o?o:"unknown").toLowerCase(),g=null===(n=null==v?void 0:v.cc_exp_year)||void 0===n?void 0:n.substring(2),G=null==v?void 0:v.cc_exp_month,k=null===(h=null==v?void 0:v.cc_number_masked)||void 0===h?void 0:h.replace(/x/gi,"");return i(l||(l=u` <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <p class="leading-s"> <span class="block font-medium text-m" data-testid="line-1"> <foxy-i18n .options="${0}" infer="" key="price"></foxy-i18n> <span>&nbsp;&bull;&nbsp;</span> <foxy-i18n .options="${0}" infer="" key="date"></foxy-i18n> </span> <span class="block text-s text-secondary"> ${0} </span> ${0} <span class="mt-s flex space-x-s overflow-auto"> ${0} <foxy-i18n class="truncate flex font-medium h-xs items-center px-s rounded-s text-s ${0} ${0}" infer="" key="fraud_risk" .options="${0}"> </foxy-i18n> </span> </p> `),d(null!==(_=this.hostedPaymentGatewaysHelper)&&void 0!==_?_:void 0),this.__hostedPaymentGatewaysLoaderId,(()=>this.requestUpdate()),d(null!==(m=this.paymentGatewaysHelper)&&void 0!==m?m:void 0),this.__paymentGatewaysLoaderId,(()=>this.requestUpdate()),d(null==v?void 0:v._links["fx:transaction"].href),this.__transactionLoaderId,(()=>this.requestUpdate()),d(this.__canReadStore?null==v?void 0:v._links["fx:store"].href:void 0),this.__storeLoaderId,(()=>this.requestUpdate()),$,{value:null==v?void 0:v.date_created},this.__gatewayName||i(c||(c=u`<foxy-i18n infer="" key="unknown"></foxy-i18n>`)),["processor_response","paypal_payer_id","third_party_id","purchase_order"].map((e=>{if(!(null==v?void 0:v[e]))return;return i(p||(p=u`<foxy-i18n class="${0}" infer="" key="${0}" .options="${0}"></foxy-i18n>`),"block text-s text-tertiary",e,v)})),G&&g&&k?i(y||(y=u` <span class="truncate flex items-center h-xs rounded-s overflow-hidden bg-contrast-5" data-testid="card-info"> <span class="h-xs">${0}</span> <span class="font-medium px-s">•••• ${0} ${0}/${0}</span> </span> `),null!==(f=t[L])&&void 0!==f?f:a,k,G,g):"",b,j,{score:w})}get isBodyReady(){return!!super.isBodyReady&&(!!this.__currencyCode&&(!!this.__currencyDisplay&&(!this.hostedPaymentGatewaysHelper||!this.paymentGatewaysHelper||!!this.__gatewayName)))}get __hostedPaymentGatewaysLoader(){return this.renderRoot.querySelector(`#${this.__hostedPaymentGatewaysLoaderId}`)}get __paymentGatewaysLoader(){return this.renderRoot.querySelector(`#${this.__paymentGatewaysLoaderId}`)}get __transactionLoader(){return this.renderRoot.querySelector(`#${this.__transactionLoaderId}`)}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}get __canReadStore(){return s(this.currentUserScope,"stores")}get __currencyDisplay(){var e;const t=null===(e=this.__storeLoader)||void 0===e?void 0:e.data;return t||this.__canReadStore?t?t.use_international_currency_symbol?"code":"symbol":void 0:"symbol"}get __currencyCode(){var e,t;return null===(t=null===(e=this.__transactionLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.currency_code}get __gatewayName(){var e,t,a,s,r,o;const n=null===(e=this.data)||void 0===e?void 0:e.gateway_type;if(n){const e=null===(a=null===(t=this.__paymentGatewaysLoader)||void 0===t?void 0:t.data)||void 0===a?void 0:a.values[n],d=null===(r=null===(s=this.__hostedPaymentGatewaysLoader)||void 0===s?void 0:s.data)||void 0===r?void 0:r.values[n];return null!==(o=null==e?void 0:e.name)&&void 0!==o?o:null==d?void 0:d.name}}}customElements.define("foxy-payment-card",_);export{_ as PaymentCard};
1
+ import"./shared-0996f4d0.js";import"./foxy-nucleon-element.js";import"./shared-c066b7fd.js";import{_ as e}from"./shared-8f9014ff.js";import{l as t,u as a}from"./shared-cf613436.js";import{c as s}from"./shared-87e17c02.js";import{C as r}from"./shared-222b23bb.js";import{a as o}from"./shared-5b8c7250.js";import{I as n}from"./shared-56278a3c.js";import{i as d}from"./shared-53e42a77.js";import{h as i}from"./shared-ba5c42c7.js";import"./foxy-spinner.js";import"./shared-c59277a4.js";import"./shared-c3d6bcc0.js";import"./shared-f410644a.js";import"./shared-cf1965cb.js";import"./shared-930e68b7.js";import"./shared-c85c1864.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-791b4510.js";import"./shared-0e19bda5.js";import"./shared-4e709717.js";let l,c,p,u,y=e=>e;const h=r(o(n,"payment-card"));class _ extends h{constructor(){super(...arguments),this.hostedPaymentGatewaysHelper=null,this.paymentGatewaysHelper=null,this.__hostedPaymentGatewaysLoaderId="hostedPaymentGatewaysLoader",this.__paymentGatewaysLoaderId="paymentGatewaysLoader",this.__transactionLoaderId="transactionLoader",this.__storeLoaderId="storeLoader"}static get properties(){return e(e({},super.properties),{},{hostedPaymentGatewaysHelper:{attribute:"hosted-payment-gateways-helper"},paymentGatewaysHelper:{attribute:"payment-gateways-helper"}})}renderBody(){var e,s,r,o,n,h,_,m,f;const v=this.data,x=`${null!==(e=null==v?void 0:v.amount)&&void 0!==e?e:""} ${this.__currencyCode}`,w={currencyDisplay:this.__currencyDisplay,amount:x},$=null!==(r=null===(s=this.data)||void 0===s?void 0:s.fraud_protection_score)&&void 0!==r?r:0,b=$>0?"text-error":"text-success",L=$>0?"bg-error-10":"bg-success-10",j=(null!==(o=null==v?void 0:v.cc_type)&&void 0!==o?o:"unknown").toLowerCase(),g=null===(n=null==v?void 0:v.cc_exp_year)||void 0===n?void 0:n.substring(2),G=null==v?void 0:v.cc_exp_month,I=null===(h=null==v?void 0:v.cc_number_masked)||void 0===h?void 0:h.replace(/x/gi,"");return i(l||(l=y` <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <p class="leading-s"> <span class="block font-medium text-m" data-testid="line-1"> <foxy-i18n .options="${0}" infer="" key="price"></foxy-i18n> <span>&nbsp;&bull;&nbsp;</span> <foxy-i18n .options="${0}" infer="" key="date"></foxy-i18n> </span> ${0} ${0} <span class="mt-s flex space-x-s overflow-auto"> ${0} <foxy-i18n class="truncate flex font-medium h-xs items-center px-s rounded-s text-s ${0} ${0}" infer="" key="fraud_risk" .options="${0}"> </foxy-i18n> </span> </p> `),d(null!==(_=this.hostedPaymentGatewaysHelper)&&void 0!==_?_:void 0),this.__hostedPaymentGatewaysLoaderId,(()=>this.requestUpdate()),d(null!==(m=this.paymentGatewaysHelper)&&void 0!==m?m:void 0),this.__paymentGatewaysLoaderId,(()=>this.requestUpdate()),d(null==v?void 0:v._links["fx:transaction"].href),this.__transactionLoaderId,(()=>this.requestUpdate()),d(this.__canReadStore?null==v?void 0:v._links["fx:store"].href:void 0),this.__storeLoaderId,(()=>this.requestUpdate()),w,{value:null==v?void 0:v.date_created},this.__gatewayName?i(c||(c=y` <span class="block text-s text-secondary" data-testid="gateway"> ${0} </span> `),this.__gatewayName):"",["processor_response","paypal_payer_id","third_party_id","purchase_order"].map((e=>{if(!(null==v?void 0:v[e]))return;return i(p||(p=y`<foxy-i18n class="${0}" infer="" key="${0}" .options="${0}"></foxy-i18n>`),"block text-s text-tertiary",e,v)})),G&&g&&I?i(u||(u=y` <span class="truncate flex items-center h-xs rounded-s overflow-hidden bg-contrast-5" data-testid="card-info"> <span class="h-xs">${0}</span> <span class="font-medium px-s">•••• ${0} ${0}/${0}</span> </span> `),null!==(f=t[j])&&void 0!==f?f:a,I,G,g):"",b,L,{score:$})}get isBodyReady(){if(!super.isBodyReady)return!1;if(!this.__currencyCode)return!1;if(!this.__currencyDisplay)return!1;if(this.__gatewayName)return!0;const e=(e,t)=>!e||!!(null==t?void 0:t.data)||!!(null==t?void 0:t.in("fail"));return e(this.hostedPaymentGatewaysHelper,this.__hostedPaymentGatewaysLoader)&&e(this.paymentGatewaysHelper,this.__paymentGatewaysLoader)}get __hostedPaymentGatewaysLoader(){return this.renderRoot.querySelector(`#${this.__hostedPaymentGatewaysLoaderId}`)}get __paymentGatewaysLoader(){return this.renderRoot.querySelector(`#${this.__paymentGatewaysLoaderId}`)}get __transactionLoader(){return this.renderRoot.querySelector(`#${this.__transactionLoaderId}`)}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}get __canReadStore(){return s(this.currentUserScope,"stores")}get __currencyDisplay(){var e;const t=null===(e=this.__storeLoader)||void 0===e?void 0:e.data;return t||this.__canReadStore?t?t.use_international_currency_symbol?"code":"symbol":void 0:"symbol"}get __currencyCode(){var e,t;return null===(t=null===(e=this.__transactionLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.currency_code}get __gatewayName(){var e,t,a,s,r,o;const n=null===(e=this.data)||void 0===e?void 0:e.gateway_type;if(n){const e=null===(a=null===(t=this.__paymentGatewaysLoader)||void 0===t?void 0:t.data)||void 0===a?void 0:a.values[n],d=null===(r=null===(s=this.__hostedPaymentGatewaysLoader)||void 0===s?void 0:s.data)||void 0===r?void 0:r.values[n];return null!==(o=null==e?void 0:e.name)&&void 0!==o?o:null==d?void 0:d.name}}}customElements.define("foxy-payment-card",_);export{_ as PaymentCard};
@@ -1411,7 +1411,6 @@
1411
1411
  "paypal_payer_id": "PayPal Payer ID {{ paypal_payer_id }}",
1412
1412
  "third_party_id": "External ID {{ third_party_id }}",
1413
1413
  "price": "{{amount, price}}",
1414
- "unknown": "Unknown",
1415
1414
  "spinner": {
1416
1415
  "loading_busy": "Loading",
1417
1416
  "loading_empty": "No payments",
@@ -7,7 +7,6 @@
7
7
  "paypal_payer_id": "PayPal Payer ID {{ paypal_payer_id }}",
8
8
  "third_party_id": "External ID {{ third_party_id }}",
9
9
  "price": "{{amount, price}}",
10
- "unknown": "Unknown",
11
10
  "spinner": {
12
11
  "loading_busy": "Loading",
13
12
  "loading_empty": "No data",
@@ -1040,7 +1040,6 @@
1040
1040
  "paypal_payer_id": "PayPal Payer ID {{ paypal_payer_id }}",
1041
1041
  "third_party_id": "External ID {{ third_party_id }}",
1042
1042
  "price": "{{amount, price}}",
1043
- "unknown": "Unknown",
1044
1043
  "spinner": {
1045
1044
  "loading_busy": "Loading",
1046
1045
  "loading_empty": "No payments",
@@ -90,10 +90,13 @@ export class PaymentCard extends Base {
90
90
  <foxy-i18n .options=${{ value: data === null || data === void 0 ? void 0 : data.date_created }} infer="" key="date"></foxy-i18n>
91
91
  </span>
92
92
 
93
- <span class="block text-s text-secondary">
94
- ${this.__gatewayName || html `<foxy-i18n infer="" key="unknown"></foxy-i18n>`}
95
- </span>
96
-
93
+ ${this.__gatewayName
94
+ ? html `
95
+ <span class="block text-s text-secondary" data-testid="gateway">
96
+ ${this.__gatewayName}
97
+ </span>
98
+ `
99
+ : ''}
97
100
  ${infoKeys.map(key => {
98
101
  if (!(data === null || data === void 0 ? void 0 : data[key]))
99
102
  return;
@@ -132,7 +135,15 @@ export class PaymentCard extends Base {
132
135
  return false;
133
136
  if (!this.__currencyDisplay)
134
137
  return false;
135
- return !this.hostedPaymentGatewaysHelper || !this.paymentGatewaysHelper || !!this.__gatewayName;
138
+ if (this.__gatewayName)
139
+ return true;
140
+ // Wait for both helpers to settle (loaded or failed) instead of waiting for a match:
141
+ // gateway_type can be empty or missing from the helpers, and then it would never match.
142
+ const isSettled = (helper, loader) => {
143
+ return !helper || !!(loader === null || loader === void 0 ? void 0 : loader.data) || !!(loader === null || loader === void 0 ? void 0 : loader.in('fail'));
144
+ };
145
+ return (isSettled(this.hostedPaymentGatewaysHelper, this.__hostedPaymentGatewaysLoader) &&
146
+ isSettled(this.paymentGatewaysHelper, this.__paymentGatewaysLoader));
136
147
  }
137
148
  get __hostedPaymentGatewaysLoader() {
138
149
  return this.renderRoot.querySelector(`#${this.__hostedPaymentGatewaysLoader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AAC;IAED,IAAY,aAAa;;QACvB,MAAM,IAAI,SAAG,IAAI,CAAC,IAAI,0CAAE,YAAY,CAAC;QACrC,IAAI,IAAI,EAAE;YACR,MAAM,OAAO,eAAG,IAAI,CAAC,uBAAuB,0CAAE,IAAI,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YACjE,MAAM,aAAa,eAAG,IAAI,CAAC,6BAA6B,0CAAE,IAAI,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7E,aAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CAAC;SAC7C;IACH,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport * as logos from '../PaymentMethodCard/logos';\n\nimport { canReadCollection } from '../../../utils/user-scope';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'payment-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying a payment resource (`fx:payment`).\n *\n * @element foxy-payment-card\n * @since 1.11.0\n */\nexport class PaymentCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n hostedPaymentGatewaysHelper: { attribute: 'hosted-payment-gateways-helper' },\n paymentGatewaysHelper: { attribute: 'payment-gateways-helper' },\n };\n }\n\n /** URL of the `fx:hosted_payment_gateways` property helper resource. */\n hostedPaymentGatewaysHelper: string | null = null;\n\n /** URL of the `fx:payment_gateways` property helper resource. */\n paymentGatewaysHelper: string | null = null;\n\n private readonly __hostedPaymentGatewaysLoaderId = 'hostedPaymentGatewaysLoader';\n\n private readonly __paymentGatewaysLoaderId = 'paymentGatewaysLoader';\n\n private readonly __transactionLoaderId = 'transactionLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n renderBody(): TemplateResult {\n const data = this.data;\n const amount = `${data?.amount ?? ''} ${this.__currencyCode}`;\n const amountOptions = { currencyDisplay: this.__currencyDisplay, amount };\n\n const infoKeys = [\n 'processor_response',\n 'paypal_payer_id',\n 'third_party_id',\n 'purchase_order',\n ] as const;\n\n const score = this.data?.fraud_protection_score ?? 0;\n const scoreColor = score > 0 ? 'text-error' : 'text-success';\n const scoreBackground = score > 0 ? 'bg-error-10' : 'bg-success-10';\n\n const type = (data?.cc_type ?? 'unknown').toLowerCase() as keyof typeof logos;\n const year = data?.cc_exp_year?.substring(2);\n const month = data?.cc_exp_month;\n const last4Digits = data?.cc_number_masked?.replace(/x/gi, '');\n\n return html`\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.hostedPaymentGatewaysHelper ?? undefined)}\n id=${this.__hostedPaymentGatewaysLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.paymentGatewaysHelper ?? undefined)}\n id=${this.__paymentGatewaysLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(data?._links['fx:transaction'].href)}\n id=${this.__transactionLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.__canReadStore ? data?._links['fx:store'].href : undefined)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <p class=\"leading-s\">\n <span class=\"block font-medium text-m\" data-testid=\"line-1\">\n <foxy-i18n .options=${amountOptions} infer=\"\" key=\"price\"></foxy-i18n>\n <span>&nbsp;&bull;&nbsp;</span>\n <foxy-i18n .options=${{ value: data?.date_created }} infer=\"\" key=\"date\"></foxy-i18n>\n </span>\n\n <span class=\"block text-s text-secondary\">\n ${this.__gatewayName || html`<foxy-i18n infer=\"\" key=\"unknown\"></foxy-i18n>`}\n </span>\n\n ${infoKeys.map(key => {\n if (!data?.[key]) return;\n const css = 'block text-s text-tertiary';\n return html`<foxy-i18n class=${css} infer=\"\" key=${key} .options=${data}></foxy-i18n>`;\n })}\n\n <span class=\"mt-s flex space-x-s overflow-auto\">\n ${month && year && last4Digits\n ? html`\n <span\n class=\"truncate flex items-center h-xs rounded-s overflow-hidden bg-contrast-5\"\n data-testid=\"card-info\"\n >\n <span class=\"h-xs\">${logos[type] ?? logos.unknown}</span>\n <span class=\"font-medium px-s\">•••• ${last4Digits} ${month}/${year}</span>\n </span>\n `\n : ''}\n\n <foxy-i18n\n class=\"truncate flex font-medium h-xs items-center px-s rounded-s text-s ${scoreColor} ${scoreBackground}\"\n infer=\"\"\n key=\"fraud_risk\"\n .options=${{ score }}\n >\n </foxy-i18n>\n </span>\n </p>\n `;\n }\n\n get isBodyReady(): boolean {\n if (!super.isBodyReady) return false;\n if (!this.__currencyCode) return false;\n if (!this.__currencyDisplay) return false;\n return !this.hostedPaymentGatewaysHelper || !this.paymentGatewaysHelper || !!this.__gatewayName;\n }\n\n private get __hostedPaymentGatewaysLoader() {\n type Loader = NucleonElement<Resource<Rels.HostedPaymentGatewaysHelper>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__hostedPaymentGatewaysLoaderId}`);\n }\n\n private get __paymentGatewaysLoader() {\n type Loader = NucleonElement<Resource<Rels.PaymentGatewaysHelper>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__paymentGatewaysLoaderId}`);\n }\n\n private get __transactionLoader() {\n type Loader = NucleonElement<Resource<Rels.Transaction>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__transactionLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n // Payments belong to transactions, so the transaction is always readable here.\n // Without the store the price falls back to the currency symbol.\n private get __canReadStore() {\n return canReadCollection(this.currentUserScope, 'stores');\n }\n\n private get __currencyDisplay() {\n const store = this.__storeLoader?.data;\n if (!store && !this.__canReadStore) return 'symbol';\n return store ? (store.use_international_currency_symbol ? 'code' : 'symbol') : void 0;\n }\n\n private get __currencyCode() {\n return this.__transactionLoader?.data?.currency_code;\n }\n\n private get __gatewayName() {\n const type = this.data?.gateway_type;\n if (type) {\n const gateway = this.__paymentGatewaysLoader?.data?.values[type];\n const hostedGateway = this.__hostedPaymentGatewaysLoader?.data?.values[type];\n return gateway?.name ?? hostedGateway?.name;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PaymentCard.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentCard/PaymentCard.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,sCAAmC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,qCAAkC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,cAAc,CAAC;AAC1B,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,OAAO,WAAY,SAAQ,IAAU;IAA3C;;QASE,wEAAwE;QACxE,gCAA2B,GAAkB,IAAI,CAAC;QAElD,iEAAiE;QACjE,0BAAqB,GAAkB,IAAI,CAAC;QAE3B,oCAA+B,GAAG,6BAA6B,CAAC;QAEhE,8BAAyB,GAAG,u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AC7E,aAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CAAC;SAC7C;IACH,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport * as logos from '../PaymentMethodCard/logos';\n\nimport { canReadCollection } from '../../../utils/user-scope';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'payment-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Basic card displaying a payment resource (`fx:payment`).\n *\n * @element foxy-payment-card\n * @since 1.11.0\n */\nexport class PaymentCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n hostedPaymentGatewaysHelper: { attribute: 'hosted-payment-gateways-helper' },\n paymentGatewaysHelper: { attribute: 'payment-gateways-helper' },\n };\n }\n\n /** URL of the `fx:hosted_payment_gateways` property helper resource. */\n hostedPaymentGatewaysHelper: string | null = null;\n\n /** URL of the `fx:payment_gateways` property helper resource. */\n paymentGatewaysHelper: string | null = null;\n\n private readonly __hostedPaymentGatewaysLoaderId = 'hostedPaymentGatewaysLoader';\n\n private readonly __paymentGatewaysLoaderId = 'paymentGatewaysLoader';\n\n private readonly __transactionLoaderId = 'transactionLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n renderBody(): TemplateResult {\n const data = this.data;\n const amount = `${data?.amount ?? ''} ${this.__currencyCode}`;\n const amountOptions = { currencyDisplay: this.__currencyDisplay, amount };\n\n const infoKeys = [\n 'processor_response',\n 'paypal_payer_id',\n 'third_party_id',\n 'purchase_order',\n ] as const;\n\n const score = this.data?.fraud_protection_score ?? 0;\n const scoreColor = score > 0 ? 'text-error' : 'text-success';\n const scoreBackground = score > 0 ? 'bg-error-10' : 'bg-success-10';\n\n const type = (data?.cc_type ?? 'unknown').toLowerCase() as keyof typeof logos;\n const year = data?.cc_exp_year?.substring(2);\n const month = data?.cc_exp_month;\n const last4Digits = data?.cc_number_masked?.replace(/x/gi, '');\n\n return html`\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.hostedPaymentGatewaysHelper ?? undefined)}\n id=${this.__hostedPaymentGatewaysLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.paymentGatewaysHelper ?? undefined)}\n id=${this.__paymentGatewaysLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(data?._links['fx:transaction'].href)}\n id=${this.__transactionLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n infer=\"\"\n href=${ifDefined(this.__canReadStore ? data?._links['fx:store'].href : undefined)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <p class=\"leading-s\">\n <span class=\"block font-medium text-m\" data-testid=\"line-1\">\n <foxy-i18n .options=${amountOptions} infer=\"\" key=\"price\"></foxy-i18n>\n <span>&nbsp;&bull;&nbsp;</span>\n <foxy-i18n .options=${{ value: data?.date_created }} infer=\"\" key=\"date\"></foxy-i18n>\n </span>\n\n ${this.__gatewayName\n ? html`\n <span class=\"block text-s text-secondary\" data-testid=\"gateway\">\n ${this.__gatewayName}\n </span>\n `\n : ''}\n ${infoKeys.map(key => {\n if (!data?.[key]) return;\n const css = 'block text-s text-tertiary';\n return html`<foxy-i18n class=${css} infer=\"\" key=${key} .options=${data}></foxy-i18n>`;\n })}\n\n <span class=\"mt-s flex space-x-s overflow-auto\">\n ${month && year && last4Digits\n ? html`\n <span\n class=\"truncate flex items-center h-xs rounded-s overflow-hidden bg-contrast-5\"\n data-testid=\"card-info\"\n >\n <span class=\"h-xs\">${logos[type] ?? logos.unknown}</span>\n <span class=\"font-medium px-s\">•••• ${last4Digits} ${month}/${year}</span>\n </span>\n `\n : ''}\n\n <foxy-i18n\n class=\"truncate flex font-medium h-xs items-center px-s rounded-s text-s ${scoreColor} ${scoreBackground}\"\n infer=\"\"\n key=\"fraud_risk\"\n .options=${{ score }}\n >\n </foxy-i18n>\n </span>\n </p>\n `;\n }\n\n get isBodyReady(): boolean {\n if (!super.isBodyReady) return false;\n if (!this.__currencyCode) return false;\n if (!this.__currencyDisplay) return false;\n if (this.__gatewayName) return true;\n\n // Wait for both helpers to settle (loaded or failed) instead of waiting for a match:\n // gateway_type can be empty or missing from the helpers, and then it would never match.\n const isSettled = (helper: string | null, loader: NucleonElement<any> | null) => {\n return !helper || !!loader?.data || !!loader?.in('fail');\n };\n\n return (\n isSettled(this.hostedPaymentGatewaysHelper, this.__hostedPaymentGatewaysLoader) &&\n isSettled(this.paymentGatewaysHelper, this.__paymentGatewaysLoader)\n );\n }\n\n private get __hostedPaymentGatewaysLoader() {\n type Loader = NucleonElement<Resource<Rels.HostedPaymentGatewaysHelper>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__hostedPaymentGatewaysLoaderId}`);\n }\n\n private get __paymentGatewaysLoader() {\n type Loader = NucleonElement<Resource<Rels.PaymentGatewaysHelper>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__paymentGatewaysLoaderId}`);\n }\n\n private get __transactionLoader() {\n type Loader = NucleonElement<Resource<Rels.Transaction>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__transactionLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n // Payments belong to transactions, so the transaction is always readable here.\n // Without the store the price falls back to the currency symbol.\n private get __canReadStore() {\n return canReadCollection(this.currentUserScope, 'stores');\n }\n\n private get __currencyDisplay() {\n const store = this.__storeLoader?.data;\n if (!store && !this.__canReadStore) return 'symbol';\n return store ? (store.use_international_currency_symbol ? 'code' : 'symbol') : void 0;\n }\n\n private get __currencyCode() {\n return this.__transactionLoader?.data?.currency_code;\n }\n\n private get __gatewayName() {\n const type = this.data?.gateway_type;\n if (type) {\n const gateway = this.__paymentGatewaysLoader?.data?.values[type];\n const hostedGateway = this.__hostedPaymentGatewaysLoader?.data?.values[type];\n return gateway?.name ?? hostedGateway?.name;\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foxy.io/elements",
3
3
  "type": "module",
4
- "version": "1.60.2",
4
+ "version": "1.60.3",
5
5
  "description": "E-commerce web components by Foxy.",
6
6
  "repository": {
7
7
  "type": "git",