@mediquo/elements 0.6.2 → 0.6.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.
package/dist/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.6.
|
|
1
|
+
const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.6.3",n={development:{MODE:"development",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"47836441",ASSETS_BASE_URL:E},production:{MODE:"production",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"46655102",ASSETS_BASE_URL:E}};let t=o;const _=new Proxy({},{get:(E,o)=>n[t??"production"][o]});function S(E){t=E}export{E as ASSETS_BASE_URL,_ as env,S as setEnv};
|
|
@@ -2,6 +2,7 @@ import * as lit_html from 'lit-html';
|
|
|
2
2
|
import * as lit from 'lit';
|
|
3
3
|
import { LitElement, PropertyValues } from 'lit';
|
|
4
4
|
import { Env } from './env.js';
|
|
5
|
+
import './ui/mq-button.js';
|
|
5
6
|
export { MqPaymentSucceededEvent } from './events.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -21,6 +22,10 @@ export { MqPaymentSucceededEvent } from './events.js';
|
|
|
21
22
|
*
|
|
22
23
|
* @fires mq-payment-succeeded - The session reached `paid`. Carries the created
|
|
23
24
|
* appointment id, so the host can route straight to the confirmation screen.
|
|
25
|
+
* @fires mq-back - The user asked to leave a terminal error screen (the "Volver"
|
|
26
|
+
* action on the rejected / unconfirmable states). Purely a navigation hint —
|
|
27
|
+
* the host decides where "back" goes; hosts that render the poller as a
|
|
28
|
+
* dedicated return page can ignore it.
|
|
24
29
|
*/
|
|
25
30
|
declare class MqPaymentPoller extends LitElement {
|
|
26
31
|
static styles: lit.CSSResult;
|
|
@@ -47,6 +52,8 @@ declare class MqPaymentPoller extends LitElement {
|
|
|
47
52
|
private _stop;
|
|
48
53
|
private _settle;
|
|
49
54
|
private _pollOnce;
|
|
55
|
+
private _onRetry;
|
|
56
|
+
private _onBack;
|
|
50
57
|
private _renderVerifying;
|
|
51
58
|
private _renderDenied;
|
|
52
59
|
private _renderTimeout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as s,c as o}from"./chunks/custom-element-D2ziPxYE.js";import{m as
|
|
1
|
+
import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as s,c as o}from"./chunks/custom-element-D2ziPxYE.js";import{m as r}from"./chunks/runtime-Bg1WXVCx.js";import{l as a}from"./chunks/localized-decorator-BlOuLhym.js";import{a as n,P as l}from"./chunks/api-chat-client-BBL1U9EQ.js";import{i as c,a as d,x as p}from"./chunks/lit-element-DiWJYFwC.js";import{n as h}from"./chunks/property-scuRaFcM.js";import{r as u}from"./chunks/state-LQivXIgA.js";import{setEnv as m}from"./env.js";import{MqBackEvent as v,MqPaymentSucceededEvent as g}from"./events.js";import{spinnerIcon as f}from"./ui/icons/spinner-icon.js";import"./ui/mq-button.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-CJj32K_p.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./ui/icons/types.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";const y="support@mediquo.com",_=c`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;min-height:320px;padding:var(--sp-6);box-sizing:border-box}.card{width:100%;max-width:460px;box-sizing:border-box;padding:var(--sp-10);background:var(--color-card);border-radius:var(--border-radius-lg);box-shadow:var(--shadow-lg)}.verifying{display:flex;flex-direction:column;align-items:center;gap:var(--sp-4);text-align:center}.outcome{display:flex;flex-direction:column;gap:var(--sp-4)}.title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-negative);margin:0}.verifying .title{font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-semibold);color:var(--color-neutrals-text-default)}.message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-subtle);margin:0}.support a{color:var(--color-primary-text-link);font-weight:var(--font-weight-medium);text-decoration:none}.support a:hover{text-decoration:underline}.actions{display:flex;flex-direction:column;gap:var(--sp-3);margin-top:var(--sp-2)}`;let b=class MqPaymentPoller extends d{constructor(){super(...arguments),this.timeoutMs=9e4,this._view="verifying",this._deadline=0,this._settled=!1,this._onRetry=()=>{this._restart()},this._onBack=()=>{this.dispatchEvent(new v({source:"payment-poller"}))}}static{this.styles=_}willUpdate(i){i.has("env")&&this.env&&m(this.env),i.has("apiKey")&&this.apiKey&&n.setApiKey(this.apiKey),i.has("token")&&this.token&&n.setAuthToken(this.token),i.has("locale")&&this.locale&&t(this.locale)&&(e(this.locale),n.setLanguage(this.locale))}updated(t){t.has("sessionId")&&this._restart()}disconnectedCallback(){this._stop(),super.disconnectedCallback()}_restart(){this._stop(),this._settled=!1,this._view="verifying",this.sessionId&&(this._deadline=Date.now()+this.timeoutMs,this._pollOnce(),this._intervalId=setInterval(()=>{this._pollOnce()},2e3))}_stop(){void 0!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0)}_settle(t){this._stop(),this._settled=!0,this._view=t}async _pollOnce(){const t=this.sessionId;if(this._settled||!t)return;if(Date.now()>=this._deadline)return void this._settle("timeout");let e;try{e=await n.payments.getPaymentSession(t)}catch{return}return this._settled||t!==this.sessionId?void 0:e.status===l.Paid?(this._stop(),this._settled=!0,void this.dispatchEvent(new g({appointmentId:e.consultation_id,consultationType:e.consultation_type}))):void(e.status===l.Denied&&this._settle("denied"))}_renderVerifying(){return p`<div class="card"><div class="verifying" role="status" aria-live="polite">${f({size:28,color:"var(--color-primary)"})}<p class="title">${r("Confirmando tu pago")}</p><p class="message">${r("No cierres, vuelvas atrás ni actualices la ventana; esto puede tardar unos momentos.")}</p></div></div>`}_renderDenied(){return p`<div class="card"><div class="outcome" role="alert"><p class="title">${r("Tu pago no se ha completado")}</p><p class="message">${r("El pago ha sido rechazado y no hemos creado la cita. No se te ha cobrado nada: vuelve a intentarlo con otro método de pago.")}</p><div class="actions"><mq-button variant="primary" size="lg" fullwidth @click="${this._onBack}">${r("Volver")}</mq-button></div></div></div>`}_renderTimeout(){return p`<div class="card"><div class="outcome" role="alert"><p class="title">${r("Ha ocurrido un error")}</p><p class="message">${r("No hemos podido confirmar tu pago. Por favor, inténtalo de nuevo más tarde.")}</p><p class="message support">${r("Si se te ha cobrado sin una cita confirmada, contacta con nuestro equipo en")} <a href="mailto:${y}">${y}</a></p><div class="actions"><mq-button variant="primary" size="lg" fullwidth @click="${this._onRetry}">${r("Reintentar verificación")}</mq-button><mq-button variant="secondary" size="lg" fullwidth @click="${this._onBack}">${r("Volver")}</mq-button></div></div></div>`}render(){switch(this._view){case"denied":return this._renderDenied();case"timeout":return this._renderTimeout();default:return this._renderVerifying()}}};s([h({type:String,attribute:"session-id"})],b.prototype,"sessionId",void 0),s([h({type:String,attribute:"api-key"})],b.prototype,"apiKey",void 0),s([h({type:String,attribute:"token"})],b.prototype,"token",void 0),s([h({type:String,attribute:"locale"})],b.prototype,"locale",void 0),s([h({type:String,attribute:"env"})],b.prototype,"env",void 0),s([h({type:Number,attribute:"timeout-ms"})],b.prototype,"timeoutMs",void 0),s([u()],b.prototype,"_view",void 0),b=s([a(),o("mq-payment-poller")],b),i();export{b as MqPaymentPoller,g as MqPaymentSucceededEvent};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MqPaymentPoller as MqPaymentPoller$1 } from '../mq-payment-poller.js';
|
|
3
|
-
import { MqPaymentSucceededEvent } from '../events.js';
|
|
3
|
+
import { MqPaymentSucceededEvent, MqBackEvent } from '../events.js';
|
|
4
4
|
import 'lit-html';
|
|
5
5
|
import 'lit';
|
|
6
6
|
import '../env.js';
|
|
7
|
+
import '../ui/mq-button.js';
|
|
7
8
|
|
|
8
9
|
interface MqPaymentPollerProps {
|
|
9
10
|
/** Payment session to resolve, as returned when the payment was started. */
|
|
@@ -23,6 +24,12 @@ interface MqPaymentPollerProps {
|
|
|
23
24
|
* and unconfirmable payments are rendered by the element itself.
|
|
24
25
|
*/
|
|
25
26
|
onPaymentSucceeded?: (event: MqPaymentSucceededEvent) => void;
|
|
27
|
+
/**
|
|
28
|
+
* The user asked to leave a terminal error screen ("Volver"). A navigation
|
|
29
|
+
* hint only — where "back" leads is the host's call. Optional: hosts that
|
|
30
|
+
* render the poller as a dedicated return page can leave it unhandled.
|
|
31
|
+
*/
|
|
32
|
+
onBack?: (event: MqBackEvent) => void;
|
|
26
33
|
className?: string;
|
|
27
34
|
style?: React.CSSProperties;
|
|
28
35
|
id?: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{o as
|
|
2
|
+
import{o as s}from"../chunks/create-component-BB-6Gu6l.js";import*as t from"react";import{MqPaymentPoller as e}from"../mq-payment-poller.js";import"../i18n.js";import"../chunks/runtime-Bg1WXVCx.js";import"../chunks/chunk-4FFT6DC2-CVWibomC.js";import"../chunks/external-CJj32K_p.js";import"../chunks/custom-element-D2ziPxYE.js";import"../chunks/localized-decorator-BlOuLhym.js";import"../chunks/api-chat-client-BBL1U9EQ.js";import"../chunks/parseISO-Dj3qSTG8.js";import"../chunks/format-CRFiCNHw.js";import"../chunks/isBefore-CPpTogxo.js";import"../env.js";import"../chunks/lit-element-DiWJYFwC.js";import"../chunks/property-scuRaFcM.js";import"../chunks/state-LQivXIgA.js";import"../events.js";import"../ui/icons/spinner-icon.js";import"../ui/icons/types.js";import"../ui/mq-button.js";import"../chunks/class-map-Co76I6aw.js";import"../chunks/directive-2EDmOukv.js";const m=s({react:t,tagName:"mq-payment-poller",elementClass:e,events:{onPaymentSucceeded:"mq-payment-succeeded",onBack:"mq-back"}});export{m as MqPaymentPoller};
|