@foxy.io/elements 1.53.3 → 1.54.0
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-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-client-form.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-form.js +1 -1
- package/dist/cdn/foxy-custom-field-form.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.js +11 -11
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-experimental-add-to-cart-builder.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.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-integration-form.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-form.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-payments-api.js +1 -1
- package/dist/cdn/foxy-report-form.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-form.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-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-form.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-form.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-form.js +1 -1
- package/dist/cdn/{shared-ad26f72d.js → shared-13fed57b.js} +1 -1
- package/dist/cdn/{shared-e44d4a56.js → shared-6418bbb8.js} +1 -1
- package/dist/cdn/{shared-842078ca.js → shared-db8913cf.js} +1 -1
- package/dist/cdn/translations/payments-api-payment-method-form/en.json +51 -1
- package/dist/elements/internal/InternalForm/InternalForm.js +5 -3
- package/dist/elements/internal/InternalForm/InternalForm.js.map +1 -1
- package/dist/elements/internal/InternalForm/types.d.ts +2 -0
- package/dist/elements/internal/InternalForm/types.js.map +1 -1
- package/dist/elements/public/PaymentsApi/api/composers/payment_method.js +11 -5
- package/dist/elements/public/PaymentsApi/api/composers/payment_method.js.map +1 -1
- package/dist/elements/public/PaymentsApi/api/composers/payment_methods.js +1 -0
- package/dist/elements/public/PaymentsApi/api/composers/payment_methods.js.map +1 -1
- package/dist/elements/public/PaymentsApi/api/composers/payment_preset.js +1 -0
- package/dist/elements/public/PaymentsApi/api/composers/payment_preset.js.map +1 -1
- package/dist/elements/public/PaymentsApi/api/types.d.ts +3 -0
- package/dist/elements/public/PaymentsApi/api/types.js.map +1 -1
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.d.ts +14 -0
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js +197 -16
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js.map +1 -1
- package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.d.ts +2 -0
- package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.js +4 -0
- package/dist/elements/public/PaymentsApiPaymentPresetForm/PaymentsApiPaymentPresetForm.js.map +1 -1
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-a6b2bd14.js";import"./shared-8449b585.js";import"./shared-ee48a1ed.js";import"./shared-a339f79c.js";import{I as e}from"./shared-
|
|
1
|
+
import"./shared-a6b2bd14.js";import"./shared-8449b585.js";import"./shared-ee48a1ed.js";import"./shared-a339f79c.js";import{I as e}from"./shared-13fed57b.js";import{a as t}from"./shared-2bb1f0f4.js";import"./shared-9b35fe34.js";import{i as s}from"./shared-53e42a77.js";import{h as o}from"./shared-ba5c42c7.js";import{c as r,_ as n,B as i}from"./shared-8f9014ff.js";import{S as a,a as l}from"./shared-887ac0b0.js";import{v as d}from"./shared-b738ee96.js";import{c}from"./shared-4e709717.js";let h,p=e=>e;customElements.define("foxy-internal-customer-form-legal-notice-control",class extends t{renderControl(){var e,t;const r=this.nucleon;return o(h||(h=p` <p class="leading-s text-xs text-secondary"> <foxy-i18n infer="" key="text"></foxy-i18n> <a class="font-medium text-body rounded hover-underline focus-outline-none focus-ring-2 focus-ring-primary-50" target="_blank" href="${0}" rel="noopener noreferrer"> <foxy-i18n infer="" key="link"></foxy-i18n> </a> </p> `),s(null===(t=null===(e=null==r?void 0:r.settings)||void 0===e?void 0:e.tos_checkbox_settings)||void 0===t?void 0:t.url))}});var u=r((function(e){!function(){const t=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],s=(e,s=t,o="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=e||"";s[0].minDiversity=0,s[0].minLength=0;const n=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];o&&n.push({regex:`[${o}]`,message:"symbol"});let i={};i.contains=n.filter((e=>new RegExp(`${e.regex}`).test(r))).map((e=>e.message)),i.length=r.length;let a=s.filter((e=>i.contains.length>=e.minDiversity)).filter((e=>i.length>=e.minLength)).sort(((e,t)=>t.id-e.id)).map((e=>({id:e.id,value:e.value})));return Object.assign(i,a[0]),i};e.exports={passwordStrength:s,defaultOptions:t}}()}));let m,f,_=e=>e;const g=a(l(e,"customer-form")),x=u.passwordStrength;class v extends g{constructor(){super(...arguments),this.passwordless=!1,this.settings=null,this.__passwordGeneratorOptions={checkStrength:e=>x(e).id>=2},this.__isAnonymousGetValue=()=>{var e;return!1===(null===(e=this.form)||void 0===e?void 0:e.is_anonymous)?"false":"true"},this.__isAnonymousSetValue=e=>{const t="true"===e;this.edit({is_anonymous:t}),t&&this.form.password&&this.edit({password:""}),t&&this.form.password_old&&this.edit({password_old:""}),t&&this.form.forgot_password&&this.edit({forgot_password:""})},this.__isAnonymousOptions=[{value:"true",label:"option_true"},{value:"false",label:"option_false"}],this.__refreshInterval=null}static get scopedElements(){return{"foxy-internal-customer-form-legal-notice-control":customElements.get("foxy-internal-customer-form-legal-notice-control"),"foxy-internal-radio-group-control":customElements.get("foxy-internal-radio-group-control"),"foxy-internal-timestamps-control":customElements.get("foxy-internal-timestamps-control"),"foxy-internal-password-control":customElements.get("foxy-internal-password-control"),"foxy-internal-submit-control":customElements.get("foxy-internal-submit-control"),"foxy-internal-delete-control":customElements.get("foxy-internal-delete-control"),"foxy-internal-text-control":customElements.get("foxy-internal-text-control"),"foxy-internal-undo-control":customElements.get("foxy-internal-undo-control"),"foxy-copy-to-clipboard":customElements.get("foxy-copy-to-clipboard"),"foxy-spinner":customElements.get("foxy-spinner"),"vcf-tooltip":customElements.get("vcf-tooltip"),"foxy-i18n":customElements.get("foxy-i18n"),"h-captcha":customElements.get("h-captcha"),"vaadin-button":customElements.get("vaadin-button")}}static get properties(){return n(n({},super.properties),{},{passwordless:{type:Boolean},settings:{type:Object}})}static get v8n(){return[({password:e,_links:t,is_anonymous:s=!0},o)=>!!o.passwordless||(!!(t||s||e)||"password:v8n_required"),({password_old:e,password:t,_links:s},o)=>{var r;return!s||(void 0===(null===(r=o.settings)||void 0===r?void 0:r.sign_up)||(!(t&&!e)||"password-old:v8n_required"))},({first_name:e})=>!e||e.length<=50||"first-name:v8n_too_long",({last_name:e})=>!e||e.length<=50||"last-name:v8n_too_long",({password:e})=>!e||x(e).id>=2||"password:v8n_too_weak",({password:e})=>!e||e.length<=50||"password:v8n_too_long",({tax_id:e})=>!e||e.length<=50||"tax-id:v8n_too_long",({email:e})=>e&&e.length>0||"email:v8n_required",({email:e})=>!e||e.length<=100||"email:v8n_too_long",({email:e})=>!e||d(e)||"email:v8n_invalid_email"]}get hiddenSelector(){const e=new Set(super.hiddenSelector.toString().split(" "));return this.settings?(e.add("forgot-password"),e.add("is-anonymous"),this.form.password||e.add("password-old"),"none"===this.settings.tos_checkbox_settings.usage&&e.add("legal-notice")):(!1!==this.form.is_anonymous&&(e.add("forgot-password"),e.add("password")),e.add("password-old"),e.add("legal-notice")),this.href&&(e.add("is-anonymous"),e.add("legal-notice")),new i(Array.from(e).join(" ").trim())}get headerTitleOptions(){var e,t;const s=this.data;return!s||(null===(e=s.first_name)||void 0===e?void 0:e.trim())||(null===(t=s.last_name)||void 0===t?void 0:t.trim())?super.headerTitleOptions:n(n({},super.headerTitleOptions),{},{context:"no_name"})}get headerSubtitleKey(){var e;return(null===(e=this.data)||void 0===e?void 0:e.is_anonymous)?"subtitle_anonymous":"subtitle_registered"}get headerSubtitleOptions(){return n(n({},super.headerSubtitleOptions),{},{id:this.headerCopyIdValue})}disconnectedCallback(){super.disconnectedCallback();const e=this.__refreshInterval;e&&clearInterval(e)}connectedCallback(){super.connectedCallback();const e=setInterval((()=>this.requestUpdate()),6e4);this.__refreshInterval=e}renderBody(){var e,t,s,r;const n=this.hiddenSelector.matches("first-name",!0),i=this.hiddenSelector.matches("last-name",!0);return o(m||(m=_` ${0} <div class="${0}"> <foxy-internal-text-control infer="first-name"></foxy-internal-text-control> <foxy-internal-text-control infer="last-name"></foxy-internal-text-control> </div> <foxy-internal-text-control helper-text="${0}" infer="email"> </foxy-internal-text-control> <foxy-internal-radio-group-control infer="is-anonymous" .getValue="${0}" .setValue="${0}" .options="${0}"> </foxy-internal-radio-group-control> <foxy-internal-password-control placeholder="${0}" helper-text="${0}" infer="password" show-generator .generatorOptions="${0}"> </foxy-internal-password-control> <foxy-internal-password-control infer="password-old"></foxy-internal-password-control> <foxy-internal-password-control helper-text="${0}" infer="forgot-password" show-generator> </foxy-internal-password-control> <foxy-internal-text-control infer="tax-id"></foxy-internal-text-control> <foxy-internal-customer-form-legal-notice-control infer="legal-notice"> </foxy-internal-customer-form-legal-notice-control> ${0} ${0} `),this.renderHeader(),c({"grid-cols-2":!n&&!i,hidden:n&&i,"gap-m":!0,grid:!n||!i}),this.__emailHelperText,this.__isAnonymousGetValue,this.__isAnonymousSetValue,this.__isAnonymousOptions,this.__passwordPlaceholder,this.__passwordHelperText,this.__passwordGeneratorOptions,this.__forgotPasswordHelperText,!this.data&&(null===(t=null===(e=this.settings)||void 0===e?void 0:e.sign_up)||void 0===t?void 0:t.enabled)&&"hcaptcha"===(null===(r=null===(s=this.settings)||void 0===s?void 0:s.sign_up)||void 0===r?void 0:r.verification.type)?o(f||(f=_` <h-captcha site-key="${0}" class="hidden" size="invisible" hl="${0}" @verified="${0}"> </h-captcha> `),this.settings.sign_up.verification.site_key,this.lang,(({token:e})=>{this.edit({verification:{type:"hcaptcha",token:e}}),super.submit()})):"",super.renderBody())}submit(){var e,t,s,o,r;"hcaptcha"!==(null===(s=null===(t=null===(e=this.settings)||void 0===e?void 0:e.sign_up)||void 0===t?void 0:t.verification)||void 0===s?void 0:s.type)||this.data?super.submit():(null===(o=this.__hcaptcha)||void 0===o||o.reset(),null===(r=this.__hcaptcha)||void 0===r||r.execute())}async _sendPatch(e){const t=await super._sendPatch(e);if(e.password){const e={key:"password_change_success",options:{email:t.email}};this.status=e}return t}async _sendGet(){return this.status=null,await super._sendGet()}async _fetch(...e){try{return await super._fetch(...e)}catch(e){let t;try{t=(await e.json())._embedded["fx:errors"][0].message}catch(t){throw e}throw"Conflict"===t||t.startsWith("This email address is already in use")?["error:email_already_used"]:t.startsWith("Customer registration is disabled")?["error:registration_disabled"]:t.startsWith("Client verification failed")?["error:verification_failed"]:t.startsWith("Provided password is incorrect")?["error:old_password_incorrect"]:e}}get __forgotPasswordHelperText(){var e,t;const s=null===(e=this.data)||void 0===e?void 0:e.forgot_password_timestamp,o="forgot-password.helper_text";if((null===(t=this.data)||void 0===t?void 0:t.forgot_password)&&s){const e=new Date(new Date(s).getTime()+18e5),t=Math.floor((e.getTime()-Date.now())/1e3/60);return t<=0?this.t(`${o}_expired_on`,{expiresOn:e}):this.t(`${o}_expires_in`,{expiresInMin:`${t}minutes`})}return this.t(o)}get __passwordPlaceholder(){return this.data?this.t("password.placeholder_new"):this.t("password.placeholder")}get __passwordHelperText(){return this.data?this.t("password.helper_text_new"):this.t("password.helper_text")}get __emailHelperText(){var e;return(null===(e=this.data)||void 0===e?void 0:e.last_login_date)?this.t("email.helper_text_last_login_date",{date:this.data.last_login_date}):this.t("email.helper_text")}get __hcaptcha(){return this.renderRoot.querySelector("h-captcha")}}customElements.define("foxy-customer-form",v);export{v as C,u};
|
|
@@ -22,6 +22,15 @@
|
|
|
22
22
|
"conflict_message": "Remove {{ name }} to use this method",
|
|
23
23
|
"no_oauth_support_message": "Adding this gateway is currently restricted from this admin. Please utilise our legacy administration to connect this gateway to your payment set.",
|
|
24
24
|
"search_placeholder": "Search by name",
|
|
25
|
+
"status": {
|
|
26
|
+
"close": "Close",
|
|
27
|
+
"connect_error": "{{ message }}",
|
|
28
|
+
"connect_error_unknown": "We couldn't start the connection. Please try again.",
|
|
29
|
+
"connect_error_ppcp_unsupported": "Card payments through PayPal aren't available in your store's country. Choose PayPal Checkout instead."
|
|
30
|
+
},
|
|
31
|
+
"connect-spinner": {
|
|
32
|
+
"loading_busy": "Connecting..."
|
|
33
|
+
},
|
|
25
34
|
"test-group": {
|
|
26
35
|
"label": "Test setup",
|
|
27
36
|
"label_inactive": "Test setup (inactive)",
|
|
@@ -145,6 +154,47 @@
|
|
|
145
154
|
"v8n_too_long": "Please reduce this description to a 100 characters or less"
|
|
146
155
|
}
|
|
147
156
|
},
|
|
157
|
+
"connection": {
|
|
158
|
+
"label": "",
|
|
159
|
+
"helper_text": "",
|
|
160
|
+
"status_connected": "Connected as {{ email }}",
|
|
161
|
+
"redirect_notice": "You'll be redirected to finish setup.",
|
|
162
|
+
"connect-spinner": {
|
|
163
|
+
"loading_busy": "Connecting..."
|
|
164
|
+
},
|
|
165
|
+
"default": {
|
|
166
|
+
"label": "Connect this gateway",
|
|
167
|
+
"description": "You'll sign in to the gateway and approve access, then come back here.",
|
|
168
|
+
"button": "Connect"
|
|
169
|
+
},
|
|
170
|
+
"reconnect": {
|
|
171
|
+
"label": "Reconnect",
|
|
172
|
+
"description": "Reconnect if payments stop working or the gateway asks for new permissions.",
|
|
173
|
+
"button": "Reconnect"
|
|
174
|
+
},
|
|
175
|
+
"paypal_platform": {
|
|
176
|
+
"ppcp": {
|
|
177
|
+
"label": "PayPal Checkout with card payments",
|
|
178
|
+
"description": "Available in select countries.",
|
|
179
|
+
"button": "Connect"
|
|
180
|
+
},
|
|
181
|
+
"express_checkout": {
|
|
182
|
+
"label": "PayPal Checkout",
|
|
183
|
+
"description": "Available in select countries.",
|
|
184
|
+
"button": "Connect"
|
|
185
|
+
},
|
|
186
|
+
"reconnect": {
|
|
187
|
+
"label": "Reconnect",
|
|
188
|
+
"description": "Refreshes permissions, such as Apple Pay. Use the same PayPal email. To switch to another account, remove this gateway and connect again.",
|
|
189
|
+
"button": "Reconnect"
|
|
190
|
+
},
|
|
191
|
+
"reconnect_with_cards": {
|
|
192
|
+
"label": "Add card payments",
|
|
193
|
+
"description": "This account accepts PayPal only. Reconnect to also accept cards. If you have active PayPal subscriptions, use the same PayPal email.",
|
|
194
|
+
"button": "Reconnect with card payments"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
148
198
|
"account-id": {
|
|
149
199
|
"label": "Account ID"
|
|
150
200
|
},
|
|
@@ -187,4 +237,4 @@
|
|
|
187
237
|
"create": {
|
|
188
238
|
"caption": "Create"
|
|
189
239
|
}
|
|
190
|
-
}
|
|
240
|
+
}
|
|
@@ -238,19 +238,21 @@ export class InternalForm extends Base {
|
|
|
238
238
|
</foxy-i18n>
|
|
239
239
|
`;
|
|
240
240
|
}
|
|
241
|
-
__renderStatus({ key, options }) {
|
|
241
|
+
__renderStatus({ key, options, type = 'success' }) {
|
|
242
242
|
if (this.hiddenSelector.matches('status', true))
|
|
243
243
|
return;
|
|
244
244
|
return html `
|
|
245
245
|
<p
|
|
246
246
|
data-testid="status"
|
|
247
|
-
class="leading-xs text-body rounded
|
|
247
|
+
class="leading-xs text-body rounded ${type === 'error'
|
|
248
|
+
? 'bg-error-10'
|
|
249
|
+
: 'bg-success-10'} flex items-start gap-m"
|
|
248
250
|
style="padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
|
|
249
251
|
>
|
|
250
252
|
<foxy-i18n class="flex-1" infer="status" key=${key} .options=${options}></foxy-i18n>
|
|
251
253
|
<vaadin-button
|
|
252
254
|
class="flex-shrink-0"
|
|
253
|
-
theme="
|
|
255
|
+
theme="${type} tertiary-inline"
|
|
254
256
|
@click=${() => (this.status = null)}
|
|
255
257
|
>
|
|
256
258
|
<foxy-i18n class="flex-1" infer="status" key="close"></foxy-i18n>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalForm.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalForm/InternalForm.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,cAAc,EAAE,sDAAmD;AAC5E,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,IAAI,GAAG,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,OAAO,YAA4C,SAAQ,IAAW;IAA5E;;QAWE,yFAAyF;QACzF,WAAM,GAAkB,IAAI,CAAC;IAqP/B,CAAC;IA7PC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;SACzB,CAAC;IACJ,CAAC;IAKD;;;OAGG;IACH,6DAA6D;IAC7D,mBAAmB,CAAC,IAAW;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,yEAAyE;IACzE,IAAI,cAAc;QAChB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,wEAAwE;IACxE,IAAI,kBAAkB;QACpB,OAAO;YACL,GAAG,IAAI,CAAC,IAAI;YACZ,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK;YACvC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,C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AA+B,EAAE,CAAC,gBAAgB;SACnD,CAAC;;;qBAGS,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU;oBAC1C,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;;;;YAI1C,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;YAC5B,CAAC,CAAC,IAAI,CAAA;+DAC6C,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE;;;eAGpE;YACH,CAAC,CAAC,EAAE;;;KAGX,CAAC;IACJ,CAAC;IAED,IAAY,eAAe;QACzB,MAAM,MAAM,GAAI,IAAI,CAAC,WAAmC,CAAC,kBAAkB,CAAC;QAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;IAEO,oBAAoB,CAAC,GAAW;QACtC,OAAO,IAAI,CAAA;;;;;cAKD,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;;;KAGlC,CAAC;IACJ,CAAC;IAEO,cAAc,CAAC,EAAE,GAAG,EAAE,OAAO,EAAU;QAC7C,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;YAAE,OAAO;QACxD,OAAO,IAAI,CAAA;;;;;;uDAMwC,GAAG,aAAa,OAAO;;;;mBAI3D,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;;;;KAKxC,CAAC;IACJ,CAAC;;AA/PD,8EAA8E;AACvE,+BAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { HALJSONResource } from '../../public/NucleonElement/types';\nimport type { TemplateResult } from 'lit-html';\nimport type { Badge, Status } from './types';\n\nimport { BooleanSelector, getResourceId } from '@foxy.io/sdk/core';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { NucleonElement } from '../../public/NucleonElement/NucleonElement';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nconst Base = ConfigurableMixin(ThemeableMixin(NucleonElement));\n\n/**\n * An internal base class for any nucleon-powered form. Renders create/delete\n * buttons and timestamps by default, displays a spinner in non-idle states.\n *\n * @element foxy-internal-form\n * @since 1.17.0\n */\nexport class InternalForm<TData extends HALJSONResource> extends Base<TData> {\n /** Validation errors with this prefix will show up at the top of the form. */\n static generalErrorPrefix = 'error:';\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n status: { type: Object },\n };\n }\n\n /** Status message to render at the top of the form. If `null`, the message is hidden. */\n status: null | Status = null;\n\n /**\n * Renders header actions when the optional header is rendered.\n * Empty by default.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n renderHeaderActions(data: TData): TemplateResult | null {\n return null;\n }\n\n /** Getter that returns a i18n key for the optional form header title. */\n get headerTitleKey(): string {\n return 'title';\n }\n\n /** I18next options to pass to the header title translation function. */\n get headerTitleOptions(): Record<string, unknown> {\n return {\n ...this.data,\n context: this.data ? 'existing' : 'new',\n id: this.data ? getResourceId(this.data._links.self.href) : null,\n };\n }\n\n /** Getter that returns a i18n key for the optional form header subtitle. Note that subtitle is shown only when data is avaiable. */\n get headerSubtitleKey(): string {\n return 'subtitle';\n }\n\n /** I18next options to pass to the header subtitle translation function. Note that subtitle is shown only when data is avaiable. */\n get headerSubtitleOptions(): Record<string, unknown> {\n return this.data ?? {};\n }\n\n /** Getter that returns a list of the optional badges to put into the subtitle. The badges are shown only if subtitle is visible. */\n get headerSubtitleBadges(): Badge[] {\n return [];\n }\n\n /** ID that will be written to clipboard when Copy ID button in header is clicked. */\n get headerCopyIdValue(): string | number {\n return this.data ? getResourceId(this.data._links.self.href) ?? '' : '';\n }\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n if (this.href) alwaysMatch.unshift('create');\n if (!this.href) alwaysMatch.unshift('delete', 'timestamps', 'submit');\n if (!this.in({ idle: { snapshot: 'dirty' } })) alwaysMatch.unshift('undo', 'submit');\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n /**\n * Renders optional form header.\n * - Customize which actions are rendered with `.renderHeaderActions()` method.\n * - Customize the header title and subtitle with `.headerTitleKey` and `.headerSubtitleKey` getters.\n * - Customize the header title and subtitle options with `.headerTitleOptions` and `.headerSubtitleOptions` getters.\n * - To hide the header completely, add `header` to `hidden-controls` attribute.\n */\n renderHeader(): TemplateResult {\n if (this.hiddenSelector.matches('header', true)) return html``;\n\n const data = this.data;\n const actions = data ? this.renderHeaderActions(data) : null;\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('header:before')}\n <h2 class=\"grid gap-xs\">\n <span class=\"flex items-center gap-s leading-none text-xl font-medium break-all\">\n <foxy-i18n\n options=${JSON.stringify(this.headerTitleOptions)}\n infer=\"header\"\n key=${this.headerTitleKey}\n >\n </foxy-i18n>\n ${data\n ? html`\n ${this.hiddenSelector.matches('header:copy-id', true)\n ? ''\n : html`\n <foxy-copy-to-clipboard\n infer=\"header copy-id\"\n class=\"text-m\"\n text=${this.headerCopyIdValue}\n >\n </foxy-copy-to-clipboard>\n `}\n ${this.hiddenSelector.matches('header:copy-json', true)\n ? ''\n : html`\n <foxy-copy-to-clipboard\n infer=\"header copy-json\"\n class=\"text-m\"\n icon=\"icons:code\"\n text=${JSON.stringify(data, null, 2)}\n >\n </foxy-copy-to-clipboard>\n `}\n `\n : ''}\n </span>\n ${data\n ? html`\n <div class=\"flex flex-wrap items-center gap-s leading-xs\">\n ${this.headerSubtitleBadges.map(badge => {\n return html`\n <span\n data-testclass=\"badge\"\n class=${classMap({\n 'inline-flex gap-xs items-center rounded-s px-xs': true,\n [badge.class ?? 'bg-contrast-5']: true,\n })}\n >\n ${badge.icon}\n ${'text' in badge\n ? badge.text\n : html`<foxy-i18n infer=\"header badges\" key=${badge.key}></foxy-i18n>`}\n </span>\n `;\n })}\n <foxy-i18n\n infer=\"header\"\n class=\"text-secondary\"\n key=${this.headerSubtitleKey}\n .options=${this.headerSubtitleOptions}\n >\n </foxy-i18n>\n </div>\n ${actions ? html`<div class=\"flex gap-x-m\">${actions}</div>` : ''}\n `\n : ''}\n </h2>\n ${this.renderTemplateOrSlot('header:after')}\n </div>\n `;\n }\n\n /**\n * Renders form body. This is the method you should implement in your forms\n * instead of `.render()`. If you'd like to keep the submit button and the timestamps,\n * don't forget to add `super.renderBody()` to your template.\n */\n renderBody(): TemplateResult {\n const nested = ['delete', 'undo', 'submit', 'create'];\n\n return html`\n <foxy-internal-timestamps-control infer=\"timestamps\"></foxy-internal-timestamps-control>\n\n <div class=\"flex gap-m\" ?hidden=${nested.every(v => this.hiddenSelector.matches(v, true))}>\n <foxy-internal-delete-control infer=\"delete\"></foxy-internal-delete-control>\n\n <div class=\"w-full\"></div>\n\n <foxy-internal-undo-control infer=\"undo\"> </foxy-internal-undo-control>\n <foxy-internal-submit-control infer=\"submit\"> </foxy-internal-submit-control>\n <foxy-internal-submit-control infer=\"create\" theme=\"primary success\">\n </foxy-internal-submit-control>\n </div>\n `;\n }\n\n /**\n * Renders the entire form. You should probably implement `.renderBody()`\n * instead of this method in your form to keep the spinner and the common layout features.\n */\n render(): TemplateResult {\n const isSpinnerVisible = !this.in('idle') && (!this.in({ busy: 'fetching' }) || !this.data);\n\n return html`\n <div aria-busy=${this.in('busy')} aria-live=\"polite\" class=\"relative\">\n <div\n class=${classMap({\n 'space-y-m': true,\n 'transition-all filter': true,\n 'opacity-30 blur-sm pointer-events-none': isSpinnerVisible,\n })}\n >\n ${this.__generalErrors.map(err => this.__renderGeneralError(err))}\n ${this.status ? this.__renderStatus(this.status) : ''} ${this.renderBody()}\n </div>\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'flex flex-col items-center justify-center gap-m': true,\n 'transition-opacity absolute inset-0': true,\n 'opacity-0 pointer-events-none': !isSpinnerVisible,\n })}\n >\n <foxy-spinner\n layout=${this.in('fail') ? 'vertical' : 'no-label'}\n state=${this.in('fail') ? 'error' : 'busy'}\n infer=\"spinner\"\n >\n </foxy-spinner>\n ${this.href && this.in('fail')\n ? html`\n <vaadin-button theme=\"small contrast\" @click=${() => this.refresh()}>\n <foxy-i18n infer=\"spinner\" key=\"refresh\"></foxy-i18n>\n </vaadin-button>\n `\n : ''}\n </div>\n </div>\n `;\n }\n\n private get __generalErrors() {\n const prefix = (this.constructor as typeof InternalForm).generalErrorPrefix;\n return this.errors.filter(v => v.startsWith(prefix));\n }\n\n private __renderGeneralError(err: string) {\n return html`\n <foxy-i18n\n class=\"leading-xs text-body rounded bg-error-10 block\"\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n infer=\"error\"\n key=${err.replace('error:', '')}\n >\n </foxy-i18n>\n `;\n }\n\n private __renderStatus({ key, options }: Status) {\n if (this.hiddenSelector.matches('status', true)) return;\n return html`\n <p\n data-testid=\"status\"\n class=\"leading-xs text-body rounded bg-success-10 flex items-start gap-m\"\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n <foxy-i18n class=\"flex-1\" infer=\"status\" key=${key} .options=${options}></foxy-i18n>\n <vaadin-button\n class=\"flex-shrink-0\"\n theme=\"success tertiary-inline\"\n @click=${() => (this.status = null)}\n >\n <foxy-i18n class=\"flex-1\" infer=\"status\" key=\"close\"></foxy-i18n>\n </vaadin-button>\n </p>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"InternalForm.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalForm/InternalForm.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,wCAA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,CAAC,EAAE,CAAC,MAAM,CAAC;YAC5B,CAAC,CAAC,IAAI,CAAA;+DAC6C,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE;;;eAGpE;YACH,CAAC,CAAC,EAAE;;;KAGX,CAAC;IACJ,CAAC;IAED,IAAY,eAAe;QACzB,MAAM,MAAM,GAAI,IAAI,CAAC,WAAmC,CAAC,kBAAkB,CAAC;QAC5E,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;IAEO,oBAAoB,CAAC,GAAW;QACtC,OAAO,IAAI,CAAA;;;;;cAKD,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;;;KAGlC,CAAC;IACJ,CAAC;IAEO,cAAc,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,GAAG,SAAS,EAAU;QAC/D,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;YAAE,OAAO;QACxD,OAAO,IAAI,CAAA;;;8CAG+B,IAAI,KAAK,OAAO;YACpD,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,eAAe;;;uDAG4B,GAAG,aAAa,OAAO;;;mBAG3D,IAAI;mBACJ,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;;;;KAKxC,CAAC;IACJ,CAAC;;AAjQD,8EAA8E;AACvE,+BAAkB,GAAG,QAAQ,CAAC","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { HALJSONResource } from '../../public/NucleonElement/types';\nimport type { TemplateResult } from 'lit-html';\nimport type { Badge, Status } from './types';\n\nimport { BooleanSelector, getResourceId } from '@foxy.io/sdk/core';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { NucleonElement } from '../../public/NucleonElement/NucleonElement';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nconst Base = ConfigurableMixin(ThemeableMixin(NucleonElement));\n\n/**\n * An internal base class for any nucleon-powered form. Renders create/delete\n * buttons and timestamps by default, displays a spinner in non-idle states.\n *\n * @element foxy-internal-form\n * @since 1.17.0\n */\nexport class InternalForm<TData extends HALJSONResource> extends Base<TData> {\n /** Validation errors with this prefix will show up at the top of the form. */\n static generalErrorPrefix = 'error:';\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n status: { type: Object },\n };\n }\n\n /** Status message to render at the top of the form. If `null`, the message is hidden. */\n status: null | Status = null;\n\n /**\n * Renders header actions when the optional header is rendered.\n * Empty by default.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n renderHeaderActions(data: TData): TemplateResult | null {\n return null;\n }\n\n /** Getter that returns a i18n key for the optional form header title. */\n get headerTitleKey(): string {\n return 'title';\n }\n\n /** I18next options to pass to the header title translation function. */\n get headerTitleOptions(): Record<string, unknown> {\n return {\n ...this.data,\n context: this.data ? 'existing' : 'new',\n id: this.data ? getResourceId(this.data._links.self.href) : null,\n };\n }\n\n /** Getter that returns a i18n key for the optional form header subtitle. Note that subtitle is shown only when data is avaiable. */\n get headerSubtitleKey(): string {\n return 'subtitle';\n }\n\n /** I18next options to pass to the header subtitle translation function. Note that subtitle is shown only when data is avaiable. */\n get headerSubtitleOptions(): Record<string, unknown> {\n return this.data ?? {};\n }\n\n /** Getter that returns a list of the optional badges to put into the subtitle. The badges are shown only if subtitle is visible. */\n get headerSubtitleBadges(): Badge[] {\n return [];\n }\n\n /** ID that will be written to clipboard when Copy ID button in header is clicked. */\n get headerCopyIdValue(): string | number {\n return this.data ? getResourceId(this.data._links.self.href) ?? '' : '';\n }\n\n get hiddenSelector(): BooleanSelector {\n const alwaysMatch = [super.hiddenSelector.toString()];\n if (this.href) alwaysMatch.unshift('create');\n if (!this.href) alwaysMatch.unshift('delete', 'timestamps', 'submit');\n if (!this.in({ idle: { snapshot: 'dirty' } })) alwaysMatch.unshift('undo', 'submit');\n return new BooleanSelector(alwaysMatch.join(' ').trim());\n }\n\n /**\n * Renders optional form header.\n * - Customize which actions are rendered with `.renderHeaderActions()` method.\n * - Customize the header title and subtitle with `.headerTitleKey` and `.headerSubtitleKey` getters.\n * - Customize the header title and subtitle options with `.headerTitleOptions` and `.headerSubtitleOptions` getters.\n * - To hide the header completely, add `header` to `hidden-controls` attribute.\n */\n renderHeader(): TemplateResult {\n if (this.hiddenSelector.matches('header', true)) return html``;\n\n const data = this.data;\n const actions = data ? this.renderHeaderActions(data) : null;\n\n return html`\n <div>\n ${this.renderTemplateOrSlot('header:before')}\n <h2 class=\"grid gap-xs\">\n <span class=\"flex items-center gap-s leading-none text-xl font-medium break-all\">\n <foxy-i18n\n options=${JSON.stringify(this.headerTitleOptions)}\n infer=\"header\"\n key=${this.headerTitleKey}\n >\n </foxy-i18n>\n ${data\n ? html`\n ${this.hiddenSelector.matches('header:copy-id', true)\n ? ''\n : html`\n <foxy-copy-to-clipboard\n infer=\"header copy-id\"\n class=\"text-m\"\n text=${this.headerCopyIdValue}\n >\n </foxy-copy-to-clipboard>\n `}\n ${this.hiddenSelector.matches('header:copy-json', true)\n ? ''\n : html`\n <foxy-copy-to-clipboard\n infer=\"header copy-json\"\n class=\"text-m\"\n icon=\"icons:code\"\n text=${JSON.stringify(data, null, 2)}\n >\n </foxy-copy-to-clipboard>\n `}\n `\n : ''}\n </span>\n ${data\n ? html`\n <div class=\"flex flex-wrap items-center gap-s leading-xs\">\n ${this.headerSubtitleBadges.map(badge => {\n return html`\n <span\n data-testclass=\"badge\"\n class=${classMap({\n 'inline-flex gap-xs items-center rounded-s px-xs': true,\n [badge.class ?? 'bg-contrast-5']: true,\n })}\n >\n ${badge.icon}\n ${'text' in badge\n ? badge.text\n : html`<foxy-i18n infer=\"header badges\" key=${badge.key}></foxy-i18n>`}\n </span>\n `;\n })}\n <foxy-i18n\n infer=\"header\"\n class=\"text-secondary\"\n key=${this.headerSubtitleKey}\n .options=${this.headerSubtitleOptions}\n >\n </foxy-i18n>\n </div>\n ${actions ? html`<div class=\"flex gap-x-m\">${actions}</div>` : ''}\n `\n : ''}\n </h2>\n ${this.renderTemplateOrSlot('header:after')}\n </div>\n `;\n }\n\n /**\n * Renders form body. This is the method you should implement in your forms\n * instead of `.render()`. If you'd like to keep the submit button and the timestamps,\n * don't forget to add `super.renderBody()` to your template.\n */\n renderBody(): TemplateResult {\n const nested = ['delete', 'undo', 'submit', 'create'];\n\n return html`\n <foxy-internal-timestamps-control infer=\"timestamps\"></foxy-internal-timestamps-control>\n\n <div class=\"flex gap-m\" ?hidden=${nested.every(v => this.hiddenSelector.matches(v, true))}>\n <foxy-internal-delete-control infer=\"delete\"></foxy-internal-delete-control>\n\n <div class=\"w-full\"></div>\n\n <foxy-internal-undo-control infer=\"undo\"> </foxy-internal-undo-control>\n <foxy-internal-submit-control infer=\"submit\"> </foxy-internal-submit-control>\n <foxy-internal-submit-control infer=\"create\" theme=\"primary success\">\n </foxy-internal-submit-control>\n </div>\n `;\n }\n\n /**\n * Renders the entire form. You should probably implement `.renderBody()`\n * instead of this method in your form to keep the spinner and the common layout features.\n */\n render(): TemplateResult {\n const isSpinnerVisible = !this.in('idle') && (!this.in({ busy: 'fetching' }) || !this.data);\n\n return html`\n <div aria-busy=${this.in('busy')} aria-live=\"polite\" class=\"relative\">\n <div\n class=${classMap({\n 'space-y-m': true,\n 'transition-all filter': true,\n 'opacity-30 blur-sm pointer-events-none': isSpinnerVisible,\n })}\n >\n ${this.__generalErrors.map(err => this.__renderGeneralError(err))}\n ${this.status ? this.__renderStatus(this.status) : ''} ${this.renderBody()}\n </div>\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'flex flex-col items-center justify-center gap-m': true,\n 'transition-opacity absolute inset-0': true,\n 'opacity-0 pointer-events-none': !isSpinnerVisible,\n })}\n >\n <foxy-spinner\n layout=${this.in('fail') ? 'vertical' : 'no-label'}\n state=${this.in('fail') ? 'error' : 'busy'}\n infer=\"spinner\"\n >\n </foxy-spinner>\n ${this.href && this.in('fail')\n ? html`\n <vaadin-button theme=\"small contrast\" @click=${() => this.refresh()}>\n <foxy-i18n infer=\"spinner\" key=\"refresh\"></foxy-i18n>\n </vaadin-button>\n `\n : ''}\n </div>\n </div>\n `;\n }\n\n private get __generalErrors() {\n const prefix = (this.constructor as typeof InternalForm).generalErrorPrefix;\n return this.errors.filter(v => v.startsWith(prefix));\n }\n\n private __renderGeneralError(err: string) {\n return html`\n <foxy-i18n\n class=\"leading-xs text-body rounded bg-error-10 block\"\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n infer=\"error\"\n key=${err.replace('error:', '')}\n >\n </foxy-i18n>\n `;\n }\n\n private __renderStatus({ key, options, type = 'success' }: Status) {\n if (this.hiddenSelector.matches('status', true)) return;\n return html`\n <p\n data-testid=\"status\"\n class=\"leading-xs text-body rounded ${type === 'error'\n ? 'bg-error-10'\n : 'bg-success-10'} flex items-start gap-m\"\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n <foxy-i18n class=\"flex-1\" infer=\"status\" key=${key} .options=${options}></foxy-i18n>\n <vaadin-button\n class=\"flex-shrink-0\"\n theme=\"${type} tertiary-inline\"\n @click=${() => (this.status = null)}\n >\n <foxy-i18n class=\"flex-1\" infer=\"status\" key=\"close\"></foxy-i18n>\n </vaadin-button>\n </p>\n `;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SVGTemplateResult } from 'lit-html';\n\nexport type Status = {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalForm/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SVGTemplateResult } from 'lit-html';\n\nexport type Status = {\n key: string;\n options?: unknown;\n /** Message style. Defaults to `success`. */\n type?: 'success' | 'error';\n};\n\nexport type Badge = ({ key: string } | { text: string }) & {\n class?: string;\n icon?: SVGTemplateResult;\n};\n"]}
|
|
@@ -12,12 +12,18 @@ export function compose(params) {
|
|
|
12
12
|
}
|
|
13
13
|
const presetURL = new URL(`./payment_presets/${presetId}`, base);
|
|
14
14
|
const selfURL = new URL(`./payment_presets/${presetId}/payment_methods/${methodId}`, base);
|
|
15
|
+
const links = {
|
|
16
|
+
'self': { href: selfURL.toString() },
|
|
17
|
+
'fx:store': gwLinks['fx:store'],
|
|
18
|
+
'fx:payment_preset': { href: presetURL.toString() },
|
|
19
|
+
...('fx:connect_gateway' in gwLinks
|
|
20
|
+
? { 'fx:connect_gateway': gwLinks['fx:connect_gateway'] }
|
|
21
|
+
: {}),
|
|
22
|
+
};
|
|
15
23
|
return {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
'fx:payment_preset': { href: presetURL.toString() },
|
|
20
|
-
},
|
|
24
|
+
// The API adds fx:connect_gateway only to hosted gateways that support it.
|
|
25
|
+
// v1 Graph links can't be optional, so the type says it's always there.
|
|
26
|
+
_links: links,
|
|
21
27
|
...gwProps,
|
|
22
28
|
helper,
|
|
23
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment_method.js","sourceRoot":"","sources":["../../../../../../src/elements/public/PaymentsApi/api/composers/payment_method.ts"],"names":[],"mappings":"AAsBA,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAE3D,MAAM,EAAE,GAAG,gBAAgB,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC;IAC5F,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,CAAC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C,sCAAsC,EAAE,CAAC;KACxE;SAAM;QACL,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;KACvB;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,qBAAqB,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,qBAAqB,QAAQ,oBAAoB,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IAE3F,MAAM,KAAK,GAAG;QACZ,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE;QACpC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;QAC/B,mBAAmB,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE,EAAE;QACnD,GAAG,CAAC,oBAAoB,IAAI,OAAO;YACjC,CAAC,CAAC,EAAE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE;YACzD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IAEF,OAAO;QACL,2EAA2E;QAC3E,wEAAwE;QACxE,MAAM,EAAE,KAAgC;QACxC,GAAG,OAAO;QACV,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { PaymentMethod } from '../types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nexport type HostedPaymentGatewayParams = {\n paymentMethodSetHostedPaymentGatewayId: string;\n hostedPaymentGateway: Resource<Rels.HostedPaymentGateway>;\n helper: Resource<Rels.HostedPaymentGatewaysHelper>['values'][string];\n};\n\nexport type PaymentGatewayParams = {\n paymentGateway: Resource<Rels.PaymentGateway>;\n helper: Resource<Rels.PaymentGatewaysHelper>['values'][string];\n};\n\nexport type CommonParams = {\n paymentPresetId: string;\n base: string;\n};\n\nexport type Params = CommonParams & (HostedPaymentGatewayParams | PaymentGatewayParams);\n\nexport function compose(params: Params): PaymentMethod {\n const { paymentPresetId: presetId, helper, base } = params;\n\n const gw = 'paymentGateway' in params ? params.paymentGateway : params.hostedPaymentGateway;\n const { _links: gwLinks, ...gwProps } = gw;\n\n const gwId = new URL(gwLinks.self.href).pathname.split('/').pop() as string;\n let methodId: string;\n\n if ('paymentMethodSetHostedPaymentGatewayId' in params) {\n methodId = `H${gwId}C${params.paymentMethodSetHostedPaymentGatewayId}`;\n } else {\n methodId = `R${gwId}`;\n }\n\n const presetURL = new URL(`./payment_presets/${presetId}`, base);\n const selfURL = new URL(`./payment_presets/${presetId}/payment_methods/${methodId}`, base);\n\n const links = {\n 'self': { href: selfURL.toString() },\n 'fx:store': gwLinks['fx:store'],\n 'fx:payment_preset': { href: presetURL.toString() },\n ...('fx:connect_gateway' in gwLinks\n ? { 'fx:connect_gateway': gwLinks['fx:connect_gateway'] }\n : {}),\n };\n\n return {\n // The API adds fx:connect_gateway only to hosted gateways that support it.\n // v1 Graph links can't be optional, so the type says it's always there.\n _links: links as PaymentMethod['_links'],\n ...gwProps,\n helper,\n };\n}\n"]}
|
|
@@ -28,6 +28,7 @@ export function compose(params) {
|
|
|
28
28
|
paymentMethodSetHostedPaymentGatewayId: new URL(shgw._links.self.href).pathname
|
|
29
29
|
.split('/')
|
|
30
30
|
.pop(),
|
|
31
|
+
// A matching set-hosted-gateway record means this resource is a hosted gateway.
|
|
31
32
|
hostedPaymentGateway: resource,
|
|
32
33
|
paymentPresetId: presetId,
|
|
33
34
|
helper: hostedGwsHelper.values[resource.type],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment_methods.js","sourceRoot":"","sources":["../../../../../../src/elements/public/PaymentsApi/api/composers/payment_methods.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,4BAAyB;AAanE,MAAM,UAAU,OAAO,CAAC,MAAc;;IACpC,MAAM,EACJ,qCAAqC,EAAE,KAAK,EAC5C,2BAA2B,EAAE,eAAe,EAC5C,qBAAqB,EAAE,IAAI,EAC3B,qBAAqB,EAAE,SAA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B,CAAC;gBAC1B,sCAAsC,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ;qBAC5E,KAAK,CAAC,GAAG,CAAC;qBACV,GAAG,EAAY;gBAClB,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"payment_methods.js","sourceRoot":"","sources":["../../../../../../src/elements/public/PaymentsApi/api/composers/payment_methods.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,4BAAyB;AAanE,MAAM,UAAU,OAAO,CAAC,MAAc;;IACpC,MAAM,EACJ,qCAAqC,EAAE,KAAK,EAC5C,2BAA2B,EAAE,eAAe,EAC5C,qBAAqB,EAAE,IAAI,EAC3B,qBAAqB,EAAE,SAAS,EAChC,eAAe,EAAE,QAAQ,EACzB,cAAc,EAAE,EAAE,EAClB,KAAK,EACL,IAAI,GACL,GAAG,MAAM,CAAC;IAEX,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,QAAQ,OAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,mCAAI,GAAG,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,QAAQ,OAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,mCAAI,IAAI,CAAC,CAAC;IAE1D,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,oBAAoB,QAAQ,kBAAkB,EAAE,IAAI,CAAC,CAAC;IAC9E,OAAO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,OAAO,CAAC,QAAQ,EAAE,EAAE;YAClC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE;YAClC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE;SACnC;QACD,SAAS,EAAE,EAAE,oBAAoB,EAAE,cAAc,EAAE;QACnD,cAAc,EAAE,aAAa;QAC7B,WAAW,EAAE,UAAU;QACvB,MAAM;QACN,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import type { PaymentMethods } from '../types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { compose as composePaymentMethod } from './payment_method';\n\nexport type Params = {\n paymentMethodSetHostedPaymentGateways: Resource<Rels.PaymentMethodSetHostedPaymentGateways>;\n hostedPaymentGatewaysHelper: Resource<Rels.HostedPaymentGatewaysHelper>;\n paymentGatewaysHelper: Resource<Rels.PaymentGatewaysHelper>;\n hostedPaymentGateways: Resource<Rels.HostedPaymentGateway>[];\n paymentPresetId: string;\n paymentGateway?: Resource<Rels.PaymentGateway> | 'not-on-page';\n query: string;\n base: string;\n};\n\nexport function compose(params: Params): PaymentMethods {\n const {\n paymentMethodSetHostedPaymentGateways: shgws,\n hostedPaymentGatewaysHelper: hostedGwsHelper,\n hostedPaymentGateways: hgws,\n paymentGatewaysHelper: gwsHelper,\n paymentPresetId: presetId,\n paymentGateway: gw,\n query,\n base,\n } = params;\n\n const searchParams = new URLSearchParams(query);\n const offset = parseInt(searchParams.get('offset') ?? '0');\n const limit = parseInt(searchParams.get('limit') ?? '20');\n\n const totalItems = shgws.total_items + (gw ? 1 : 0);\n const returnedItems = shgws.returned_items + (!gw || gw === 'not-on-page' ? 0 : 1);\n\n const selfURL = new URL(`/payment_presets/${presetId}/payment_methods`, base);\n selfURL.search = query;\n\n const firstURL = new URL(selfURL.toString());\n const lastURL = new URL(selfURL.toString());\n const prevURL = new URL(selfURL.toString());\n const nextURL = new URL(selfURL.toString());\n\n firstURL.searchParams.set('limit', String(limit));\n firstURL.searchParams.set('offset', String(offset));\n\n lastURL.searchParams.set('limit', String(limit));\n lastURL.searchParams.set('offset', String(Math.max(0, totalItems - limit)));\n\n prevURL.searchParams.set('limit', String(limit));\n prevURL.searchParams.set('offset', String(Math.max(0, offset - limit)));\n\n nextURL.searchParams.set('limit', String(limit));\n nextURL.searchParams.set(\n 'offset',\n String(Math.min(offset + limit, Math.max(0, totalItems - limit)))\n );\n\n const paymentMethods = [...(gw && gw !== 'not-on-page' ? [gw] : []), ...hgws].map(resource => {\n const shgw = shgws._embedded['fx:payment_method_set_hosted_payment_gateways'].find(\n r => r.hosted_payment_gateway_uri === resource._links.self.href\n );\n\n if (shgw) {\n return composePaymentMethod({\n paymentMethodSetHostedPaymentGatewayId: new URL(shgw._links.self.href).pathname\n .split('/')\n .pop() as string,\n // A matching set-hosted-gateway record means this resource is a hosted gateway.\n hostedPaymentGateway: resource as Resource<Rels.HostedPaymentGateway>,\n paymentPresetId: presetId,\n helper: hostedGwsHelper.values[resource.type],\n base,\n });\n }\n\n return composePaymentMethod({\n paymentPresetId: presetId,\n paymentGateway: resource,\n helper: gwsHelper.values[resource.type],\n base,\n });\n });\n\n return {\n _links: {\n first: { href: firstURL.toString() },\n last: { href: lastURL.toString() },\n prev: { href: prevURL.toString() },\n next: { href: nextURL.toString() },\n self: { href: selfURL.toString() },\n },\n _embedded: { 'fx:payment_methods': paymentMethods },\n returned_items: returnedItems,\n total_items: totalItems,\n offset,\n limit,\n };\n}\n"]}
|
|
@@ -11,6 +11,7 @@ export function compose(params) {
|
|
|
11
11
|
_links: {
|
|
12
12
|
'self': { href: selfURL.toString() },
|
|
13
13
|
'fx:store': setLinks['fx:store'],
|
|
14
|
+
'fx:connect_gateway': setLinks['fx:connect_gateway'],
|
|
14
15
|
'fx:payment_methods': { href: methodsURL.toString() },
|
|
15
16
|
'fx:fraud_protections': { href: protectionsURL.toString() },
|
|
16
17
|
'fx:available_payment_methods': { href: availableMethodsURL.toString() },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment_preset.js","sourceRoot":"","sources":["../../../../../../src/elements/public/PaymentsApi/api/composers/payment_preset.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAC/C,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,GAAG,GAAG,CAAC;IAE9C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAY,CAAC;IAEnF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,qBAAqB,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IAE/D,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,qBAAqB,QAAQ,kBAAkB,EAAE,IAAI,CAAC,CAAC;IAElF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,qBAAqB,QAAQ,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAExF,MAAM,mBAAmB,GAAG,IAAI,GAAG,CACjC,qBAAqB,QAAQ,4BAA4B,EACzD,IAAI,CACL,CAAC;IAEF,MAAM,4BAA4B,GAAG,IAAI,GAAG,CAC1C,qBAAqB,QAAQ,8BAA8B,EAC3D,IAAI,CACL,CAAC;IAEF,OAAO;QACL,MAAM,EAAE;YACN,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE;YACpC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC;YAChC,oBAAoB,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE,EAAE;YACrD,sBAAsB,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,QAAQ,EAAE,EAAE;YAC3D,8BAA8B,EAAE,EAAE,IAAI,EAAE,mBAAmB,CAAC,QAAQ,EAAE,EAAE;YACxE,gCAAgC,EAAE,EAAE,IAAI,EAAE,4BAA4B,CAAC,QAAQ,EAAE,EAAE;SACpF;QAED,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import type { PaymentPreset } from '../types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nexport type Params = {\n paymentMethodSet: Resource<Rels.PaymentMethodSet>;\n base: string;\n};\n\nexport function compose(params: Params): PaymentPreset {\n const { paymentMethodSet: set, base } = params;\n const { _links: setLinks, ...setProps } = set;\n\n const presetId = new URL(set._links.self.href).pathname.split('/').pop() as string;\n\n const selfURL = new URL(`./payment_presets/${presetId}`, base);\n\n const methodsURL = new URL(`./payment_presets/${presetId}/payment_methods`, base);\n\n const protectionsURL = new URL(`./payment_presets/${presetId}/fraud_protections`, base);\n\n const availableMethodsURL = new URL(\n `./payment_presets/${presetId}/available_payment_methods`,\n base\n );\n\n const availableFraudProtectionsURL = new URL(\n `./payment_presets/${presetId}/available_fraud_protections`,\n base\n );\n\n return {\n _links: {\n 'self': { href: selfURL.toString() },\n 'fx:store': setLinks['fx:store'],\n 'fx:payment_methods': { href: methodsURL.toString() },\n 'fx:fraud_protections': { href: protectionsURL.toString() },\n 'fx:available_payment_methods': { href: availableMethodsURL.toString() },\n 'fx:available_fraud_protections': { href: availableFraudProtectionsURL.toString() },\n },\n\n ...setProps,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"payment_preset.js","sourceRoot":"","sources":["../../../../../../src/elements/public/PaymentsApi/api/composers/payment_preset.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,OAAO,CAAC,MAAc;IACpC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAC/C,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,Q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Rels } from '@foxy.io/sdk/backend';\n\nexport type Params = {\n paymentMethodSet: Resource<Rels.PaymentMethodSet>;\n base: string;\n};\n\nexport function compose(params: Params): PaymentPreset {\n const { paymentMethodSet: set, base } = params;\n const { _links: setLinks, ...setProps } = set;\n\n const presetId = new URL(set._links.self.href).pathname.split('/').pop() as string;\n\n const selfURL = new URL(`./payment_presets/${presetId}`, base);\n\n const methodsURL = new URL(`./payment_presets/${presetId}/payment_methods`, base);\n\n const protectionsURL = new URL(`./payment_presets/${presetId}/fraud_protections`, base);\n\n const availableMethodsURL = new URL(\n `./payment_presets/${presetId}/available_payment_methods`,\n base\n );\n\n const availableFraudProtectionsURL = new URL(\n `./payment_presets/${presetId}/available_fraud_protections`,\n base\n );\n\n return {\n _links: {\n 'self': { href: selfURL.toString() },\n 'fx:store': setLinks['fx:store'],\n 'fx:connect_gateway': setLinks['fx:connect_gateway'],\n 'fx:payment_methods': { href: methodsURL.toString() },\n 'fx:fraud_protections': { href: protectionsURL.toString() },\n 'fx:available_payment_methods': { href: availableMethodsURL.toString() },\n 'fx:available_fraud_protections': { href: availableFraudProtectionsURL.toString() },\n },\n\n ...setProps,\n };\n}\n"]}
|
|
@@ -13,6 +13,7 @@ interface PaymentPresetRel extends Graph {
|
|
|
13
13
|
links: {
|
|
14
14
|
'self': PaymentPresetRel;
|
|
15
15
|
'fx:store': Rels.Store;
|
|
16
|
+
'fx:connect_gateway': Rels.ConnectGateway;
|
|
16
17
|
'fx:payment_methods': PaymentMethodsRel;
|
|
17
18
|
'fx:fraud_protections': FraudProtectionsRel;
|
|
18
19
|
'fx:available_payment_methods': AvailablePaymentMethodsRel;
|
|
@@ -34,6 +35,8 @@ interface PaymentMethodRel extends Graph {
|
|
|
34
35
|
'self': PaymentMethodRel;
|
|
35
36
|
'fx:store': Rels.Store;
|
|
36
37
|
'fx:payment_preset': any;
|
|
38
|
+
/** Present only for hosted gateways that support OAuth-style connections. */
|
|
39
|
+
'fx:connect_gateway': Rels.ConnectGateway;
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
42
|
interface FraudProtectionsRel extends Graph {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/elements/public/PaymentsApi/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Rels } from '@foxy.io/sdk/backend';\nimport type { Graph, Resource } from '@foxy.io/sdk/core';\n\nimport type {\n CollectionGraphLinks,\n CollectionGraphProps,\n} from '@foxy.io/sdk/dist/types/core/defaults';\n\ninterface PaymentPresetsRel extends Graph {\n curie: 'fx:payment_presets';\n props: CollectionGraphProps;\n links: CollectionGraphLinks<PaymentPresetsRel>;\n child: PaymentPresetRel;\n}\n\ninterface PaymentPresetRel extends Graph {\n curie: 'fx:payment_preset';\n props: Omit<Rels.PaymentMethodSet['props'], 'gateway_uri'>;\n links: {\n 'self': PaymentPresetRel;\n 'fx:store': Rels.Store;\n 'fx:payment_methods': PaymentMethodsRel;\n 'fx:fraud_protections': FraudProtectionsRel;\n 'fx:available_payment_methods': AvailablePaymentMethodsRel;\n 'fx:available_fraud_protections': AvailableFraudProtectionsRel;\n };\n}\n\ninterface PaymentMethodsRel extends Graph {\n curie: 'fx:payment_methods';\n props: CollectionGraphProps;\n links: CollectionGraphLinks<PaymentMethodsRel>;\n child: PaymentMethodRel;\n}\n\ninterface PaymentMethodRel extends Graph {\n curie: 'fx:payment_method';\n props: (Rels.HostedPaymentGateway['props'] | Rels.PaymentGateway['props']) & {\n helper: (\n | Rels.PaymentGatewaysHelper\n | Rels.HostedPaymentGatewaysHelper\n )['props']['values'][string];\n };\n links: {\n 'self': PaymentMethodRel;\n 'fx:store': Rels.Store;\n 'fx:payment_preset': any;\n };\n}\n\ninterface FraudProtectionsRel extends Graph {\n curie: 'fx:fraud_protections';\n props: CollectionGraphProps;\n links: CollectionGraphLinks<FraudProtectionsRel>;\n child: FraudProtectionRel;\n}\n\ninterface FraudProtectionRel extends Graph {\n curie: 'fx:fraud_protection';\n links: {\n 'self': FraudProtectionRel;\n 'fx:store': Rels.Store;\n 'fx:payment_preset': PaymentPresetRel;\n };\n props: Rels.FraudProtection['props'] & {\n helper: AvailableFraudProtectionsRel['props']['values'][string];\n };\n}\n\ninterface AvailablePaymentMethodsRel extends Graph {\n curie: 'fx:available_payment_methods';\n props: {\n values: {\n [key: string]: {\n /** The name of this payment gateway. */\n name: string;\n /** The default id you can use for testing this gateway. */\n test_id: string;\n /** The default key you can use for testing this gateway. */\n test_key: string;\n /** The description of the id field for this gateway. */\n id_description: string;\n /** The description of the key field for this gateway. */\n key_description: string;\n /** Whether or not this gateway supports 3D Secure functionality. */\n supports_3d_secure: 0 | 1;\n /** Whether or not this gateway supports authorize only instead of auth+capture. */\n supports_auth_only: 0 | 1;\n /** The default third party key you can use for testing this gateway. */\n test_third_party_key: string;\n /** The description of the third party key field for this gateway. */\n third_party_key_description: string;\n /** Whether or not this payment method is deprecated. */\n is_deprecated: boolean;\n /** Whether or not this hosted gateway supports card verification. */\n supports_card_verification: boolean;\n /** Default card verification mode if this gateway supports it. */\n card_verification: 'disabled' | 'enabled_automatically' | 'enabled_override';\n /** Default configuration for card verification amounts. This is a serialized JSON string that contains the amounts for each card type. Example: `{\"verification_amounts\": {\"visa\": 1, \"mastercard\": 1, \"american_express\": 1, \"discover\": 1, \"default\": 1}}`. */\n card_verification_config: string;\n /** If this gateway requires additional information, this will contain details about the data which needs to be collected to configure this gateway. */\n additional_fields: null | {\n blocks: {\n id: string;\n is_live: boolean;\n parent_id: string;\n fields: {\n id: string;\n type: string;\n name: string;\n options?: { name: string; value: string }[];\n optional?: boolean;\n file_type?: string;\n description?: string;\n default_value: string;\n }[];\n }[];\n };\n /** If this payment method can't be used due to a conflict with another payment method, the details about it will be here. */\n conflict?: { type: string; name: string };\n };\n };\n };\n links: {\n self: PaymentMethodRel;\n };\n}\n\ninterface AvailableFraudProtectionsRel extends Graph {\n curie: 'fx:available_fraud_protections';\n links: { self: AvailableFraudProtectionsRel };\n props: {\n values: {\n [key: string]: {\n name: string;\n /** If this fraud protection can't be used due to a conflict with another fraud protection, the details about it will be here. */\n conflict?: { type: string; name: string };\n uses_rejection_threshold: boolean;\n json: null | {\n blocks: {\n id: string;\n is_live?: boolean;\n parent_id: string;\n fields: {\n id: string;\n type: string;\n name: string;\n options?: { name: string; value: string }[];\n optional?: boolean;\n file_type?: string;\n description?: string;\n default_value: unknown;\n }[];\n }[];\n };\n };\n };\n };\n}\n\nexport type PaymentMethods = Resource<PaymentMethodsRel>;\nexport type PaymentMethod = Resource<PaymentMethodRel>;\n\nexport type PaymentPresets = Resource<PaymentPresetsRel>;\nexport type PaymentPreset = Resource<PaymentPresetRel>;\n\nexport type FraudProtections = Resource<FraudProtectionsRel>;\nexport type FraudProtection = Resource<FraudProtectionRel>;\n\nexport type AvailablePaymentMethods = Resource<AvailablePaymentMethodsRel>;\nexport type AvailableFraudProtections = Resource<AvailableFraudProtectionsRel>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/elements/public/PaymentsApi/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Rels } from '@foxy.io/sdk/backend';\nimport type { Graph, Resource } from '@foxy.io/sdk/core';\n\nimport type {\n CollectionGraphLinks,\n CollectionGraphProps,\n} from '@foxy.io/sdk/dist/types/core/defaults';\n\ninterface PaymentPresetsRel extends Graph {\n curie: 'fx:payment_presets';\n props: CollectionGraphProps;\n links: CollectionGraphLinks<PaymentPresetsRel>;\n child: PaymentPresetRel;\n}\n\ninterface PaymentPresetRel extends Graph {\n curie: 'fx:payment_preset';\n props: Omit<Rels.PaymentMethodSet['props'], 'gateway_uri'>;\n links: {\n 'self': PaymentPresetRel;\n 'fx:store': Rels.Store;\n 'fx:connect_gateway': Rels.ConnectGateway;\n 'fx:payment_methods': PaymentMethodsRel;\n 'fx:fraud_protections': FraudProtectionsRel;\n 'fx:available_payment_methods': AvailablePaymentMethodsRel;\n 'fx:available_fraud_protections': AvailableFraudProtectionsRel;\n };\n}\n\ninterface PaymentMethodsRel extends Graph {\n curie: 'fx:payment_methods';\n props: CollectionGraphProps;\n links: CollectionGraphLinks<PaymentMethodsRel>;\n child: PaymentMethodRel;\n}\n\ninterface PaymentMethodRel extends Graph {\n curie: 'fx:payment_method';\n props: (Rels.HostedPaymentGateway['props'] | Rels.PaymentGateway['props']) & {\n helper: (\n | Rels.PaymentGatewaysHelper\n | Rels.HostedPaymentGatewaysHelper\n )['props']['values'][string];\n };\n links: {\n 'self': PaymentMethodRel;\n 'fx:store': Rels.Store;\n 'fx:payment_preset': any;\n /** Present only for hosted gateways that support OAuth-style connections. */\n 'fx:connect_gateway': Rels.ConnectGateway;\n };\n}\n\ninterface FraudProtectionsRel extends Graph {\n curie: 'fx:fraud_protections';\n props: CollectionGraphProps;\n links: CollectionGraphLinks<FraudProtectionsRel>;\n child: FraudProtectionRel;\n}\n\ninterface FraudProtectionRel extends Graph {\n curie: 'fx:fraud_protection';\n links: {\n 'self': FraudProtectionRel;\n 'fx:store': Rels.Store;\n 'fx:payment_preset': PaymentPresetRel;\n };\n props: Rels.FraudProtection['props'] & {\n helper: AvailableFraudProtectionsRel['props']['values'][string];\n };\n}\n\ninterface AvailablePaymentMethodsRel extends Graph {\n curie: 'fx:available_payment_methods';\n props: {\n values: {\n [key: string]: {\n /** The name of this payment gateway. */\n name: string;\n /** The default id you can use for testing this gateway. */\n test_id: string;\n /** The default key you can use for testing this gateway. */\n test_key: string;\n /** The description of the id field for this gateway. */\n id_description: string;\n /** The description of the key field for this gateway. */\n key_description: string;\n /** Whether or not this gateway supports 3D Secure functionality. */\n supports_3d_secure: 0 | 1;\n /** Whether or not this gateway supports authorize only instead of auth+capture. */\n supports_auth_only: 0 | 1;\n /** The default third party key you can use for testing this gateway. */\n test_third_party_key: string;\n /** The description of the third party key field for this gateway. */\n third_party_key_description: string;\n /** Whether or not this payment method is deprecated. */\n is_deprecated: boolean;\n /** Whether or not this hosted gateway supports card verification. */\n supports_card_verification: boolean;\n /** Default card verification mode if this gateway supports it. */\n card_verification: 'disabled' | 'enabled_automatically' | 'enabled_override';\n /** Default configuration for card verification amounts. This is a serialized JSON string that contains the amounts for each card type. Example: `{\"verification_amounts\": {\"visa\": 1, \"mastercard\": 1, \"american_express\": 1, \"discover\": 1, \"default\": 1}}`. */\n card_verification_config: string;\n /** If this gateway requires additional information, this will contain details about the data which needs to be collected to configure this gateway. */\n additional_fields: null | {\n blocks: {\n id: string;\n is_live: boolean;\n parent_id: string;\n fields: {\n id: string;\n type: string;\n name: string;\n options?: { name: string; value: string }[];\n optional?: boolean;\n file_type?: string;\n description?: string;\n default_value: string;\n }[];\n }[];\n };\n /** If this payment method can't be used due to a conflict with another payment method, the details about it will be here. */\n conflict?: { type: string; name: string };\n };\n };\n };\n links: {\n self: PaymentMethodRel;\n };\n}\n\ninterface AvailableFraudProtectionsRel extends Graph {\n curie: 'fx:available_fraud_protections';\n links: { self: AvailableFraudProtectionsRel };\n props: {\n values: {\n [key: string]: {\n name: string;\n /** If this fraud protection can't be used due to a conflict with another fraud protection, the details about it will be here. */\n conflict?: { type: string; name: string };\n uses_rejection_threshold: boolean;\n json: null | {\n blocks: {\n id: string;\n is_live?: boolean;\n parent_id: string;\n fields: {\n id: string;\n type: string;\n name: string;\n options?: { name: string; value: string }[];\n optional?: boolean;\n file_type?: string;\n description?: string;\n default_value: unknown;\n }[];\n }[];\n };\n };\n };\n };\n}\n\nexport type PaymentMethods = Resource<PaymentMethodsRel>;\nexport type PaymentMethod = Resource<PaymentMethodRel>;\n\nexport type PaymentPresets = Resource<PaymentPresetsRel>;\nexport type PaymentPreset = Resource<PaymentPresetRel>;\n\nexport type FraudProtections = Resource<FraudProtectionsRel>;\nexport type FraudProtection = Resource<FraudProtectionRel>;\n\nexport type AvailablePaymentMethods = Resource<AvailablePaymentMethodsRel>;\nexport type AvailableFraudProtections = Resource<AvailableFraudProtectionsRel>;\n"]}
|
|
@@ -26,6 +26,12 @@ export declare class PaymentsApiPaymentMethodForm extends Base<Data> {
|
|
|
26
26
|
paymentPreset: string | null;
|
|
27
27
|
/** A function that returns a URL of a payment method icon based on the given type. */
|
|
28
28
|
getImageSrc: ((type: string) => string) | null;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the URL the gateway sends the merchant back to after a connection.
|
|
31
|
+
* Receives the `payment-preset` URL. The API appends a `status` query parameter.
|
|
32
|
+
* Defaults to the current page URL.
|
|
33
|
+
*/
|
|
34
|
+
getConnectRedirectUrl: ((paymentPreset: string) => string) | null;
|
|
29
35
|
/** URL of the linked `fx:store` resource. */
|
|
30
36
|
store: string | null;
|
|
31
37
|
private readonly __availablePaymentMethodsLoaderId;
|
|
@@ -38,6 +44,9 @@ export declare class PaymentsApiPaymentMethodForm extends Base<Data> {
|
|
|
38
44
|
private readonly __threeDSecureToggleOptions;
|
|
39
45
|
private readonly __cardVerificationOptions;
|
|
40
46
|
private __search;
|
|
47
|
+
private __connectState;
|
|
48
|
+
/** Key of the connect choice whose connection URL is being fetched. */
|
|
49
|
+
private __connectKey;
|
|
41
50
|
get hiddenSelector(): BooleanSelector;
|
|
42
51
|
renderHeader(...params: Parameters<InternalForm<Data>['renderHeader']>): TemplateResult;
|
|
43
52
|
get headerTitleOptions(): Record<string, unknown>;
|
|
@@ -52,6 +61,11 @@ export declare class PaymentsApiPaymentMethodForm extends Base<Data> {
|
|
|
52
61
|
private get __liveBlocks();
|
|
53
62
|
private get __testBlocks();
|
|
54
63
|
private __renderPaymentMethodSelector;
|
|
64
|
+
private __redirect;
|
|
65
|
+
private __getConnectChoices;
|
|
66
|
+
private __getReconnectChoice;
|
|
67
|
+
private __connect;
|
|
68
|
+
private __renderConnection;
|
|
55
69
|
private __renderPaymentMethodConfig;
|
|
56
70
|
private __renderPaymentMethodButton;
|
|
57
71
|
private __renderBlock;
|