UNPKG

@konnectio/core

Version:

Konnectio Core Frontend Integration.

116 lines (115 loc) 4.67 kB
import { At as e, D as t, E as n, Et as r, M as i, O as a, P as o, S as s, T as c, Y as l, c as u, dt as d, gt as f, k as p, o as m, p as h, r as g, s as _, t as v, u as y, y as b } from "./mitt-Dp_pykgV.js"; import { E as x, G as S, J as C, S as w, b as T, j as E, x as D } from "./SelectField-CfD2awPl.js"; import { t as O } from "./_-13YE3WJt.js"; import { t as k } from "./ErrorMessage-B6saHmHE.js"; import { n as A, t as j } from "./Field-BjtJJFJG.js"; import { t as M } from "./style-Bpqv9k-3.js"; import { t as N } from "./ActionField-DlqhtdHW.js"; import { t as P } from "./giftCard-3Rb6QoQd.js"; //#region src/components/skeletons/GiftCardValidationSkeleton.vue?vue&type=script&setup=true&lang.ts var F = { class: "gift-card-validation-skeleton" }, I = { class: "gift-card-validation-skeleton-form" }, L = { class: "gift-card-validation-skeleton-text" }, R = { class: "gift-card-validation-skeleton-input" }, z = /* @__PURE__ */ w(/* @__PURE__ */ o({ __name: "GiftCardValidationSkeleton", setup(e) { return (e, t) => (l(), p("div", F, [n("div", I, [n("div", L, [ i(A, { height: "20px" }), i(A, { height: "15px" }), i(A, { height: "15px" }) ]), n("div", R, [i(j), i(j, { "no-label": "" })])])])); } }), [["__scopeId", "data-v-b1601b74"]]), B = ["innerHTML"], V = { key: 0, id: "konnectio-gift-card-validation-resume", class: "konnectio-panel" }, H = /* @__PURE__ */ w(/* @__PURE__ */ o({ name: "GiftCardValidationLayout", __name: "GiftCardValidation", props: { accessToken: {}, styling: {} }, setup(o) { let u = o, h = c(() => ({ panelMaxWidth: "800px", ...u.styling })), { t: g } = m(), { voucher: _, isValid: v, amount: w, expirationDate: A, productName: j, isLoading: M } = y(E()), { currency: F, hasError: I } = y(x()), { fetchMetadata: L } = P(), { apply: R } = E(); return (c, u) => (l(), t(T, { styling: h.value }, { default: d(() => [(l(), t(s, null, { default: d(() => [i(O, { "access-token": o.accessToken, callback: r(L) }, { default: d(() => [r(I) ? (l(), t(k, { key: 1, title: "Unable to render Gift card validation module", description: "Gift card functionality hasn't been setup for this account. Please contact Octopus PMS for support." })) : (l(), p("form", { key: 0, id: "konnectio-gift-card-validation-module", onSubmit: u[3] ||= b((e) => r(R)(), ["prevent"]) }, [ n("h4", null, [n("span", null, e(r(g)("giftCardValidation.title")), 1)]), n("p", { innerHTML: r(g)("giftCardValidation.description") }, null, 8, B), i(N, { modelValue: r(_), "onUpdate:modelValue": u[0] ||= (e) => f(_) ? _.value = e : null, icon: "gift-card", label: r(g)("booking.reservation.giftCardCode"), buttonLabel: r(g)("giftCardValidation.submitButton"), placeholder: "XXXXXXXX", "is-loading": r(M), "onUpdate:isLoading": u[1] ||= (e) => f(M) ? M.value = e : null, onAction: u[2] ||= (e) => r(R)() }, null, 8, [ "modelValue", "label", "buttonLabel", "is-loading" ]), !r(M) && r(v) ? (l(), p("table", V, [n("thead", null, [n("tr", null, [ n("th", null, [n("span", null, e(r(g)("giftCardValidation.giftCard")), 1), i(D, { icon: "gift-card", type: "fas", color: "header" })]), n("th", null, [n("span", null, e(r(g)("giftCardValidation.balance")), 1), i(D, { icon: "money-bill", type: "fas", color: "header" })]), n("th", null, [n("span", null, e(r(g)("giftCardValidation.expirationDate")), 1), i(D, { icon: "timer", type: "fas", color: "header" })]) ])]), n("tbody", null, [n("tr", null, [ n("td", null, [n("span", null, e(r(j)), 1)]), n("td", null, [n("span", null, e(r(C)(r(w), r(F))), 1)]), n("td", null, [n("span", null, e(r(S)(r(A))), 1)]) ])])])) : a("", !0) ], 32))]), _: 1 }, 8, ["access-token", "callback"])]), fallback: d(() => [i(z)]), _: 1 }))]), _: 1 }, 8, ["styling"])); } }), [["__scopeId", "data-v-ca768ef6"]]), U = u(), W = v(), G = class extends HTMLElement { vueApp; constructor() { super(); } disconnectedCallback() { this.vueApp.unmount(); } connectedCallback() { let e = _(H, this.attributes); this.vueApp = h(H, e), this.vueApp.provide("emitter", W), this.vueApp.use(U), this.vueApp.use(g), this.vueApp.use(M); let t = document.createElement("div"); this.vueApp.mount(t), this.appendChild(t.children[0]); } }; window.customElements.define("konnectio-gift-card-validation", G); //#endregion export { G as default };