UNPKG

@konnectio/core

Version:

Konnectio Core Frontend Integration.

702 lines (701 loc) 19.6 kB
import { A as e, At as t, C as n, D as r, Dt as i, E as a, Et as o, H as s, M as c, O as l, P as u, T as d, U as f, V as p, W as ee, Y as m, _ as h, bt as g, d as _, dt as v, et as y, ft as b, j as x, k as S, kt as C, lt as w, o as T, q as E, st as te, tt as ne, u as re, v as D } from "./mitt-Dp_pykgV.js"; import { E as O, F as ie, S as k, W as A, _ as j, it as ae, n as M, x as N } from "./SelectField-CfD2awPl.js"; //#region node_modules/body-scroll-lock/lib/bodyScrollLock.esm.js function P(e) { if (Array.isArray(e)) { for (var t = 0, n = Array(e.length); t < e.length; t++) n[t] = e[t]; return n; } else return Array.from(e); } var F = !1; if (typeof window < "u") { var I = { get passive() { F = !0; } }; window.addEventListener("testPassive", null, I), window.removeEventListener("testPassive", null, I); } var L = typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1), R = [], z = !1, B = -1, V = void 0, H = void 0, U = void 0, W = function(e) { return R.some(function(t) { return !!(t.options.allowTouchMove && t.options.allowTouchMove(e)); }); }, G = function(e) { var t = e || window.event; return W(t.target) || t.touches.length > 1 ? !0 : (t.preventDefault && t.preventDefault(), !1); }, K = function(e) { if (U === void 0) { var t = !!e && e.reserveScrollBarGap === !0, n = window.innerWidth - document.documentElement.clientWidth; if (t && n > 0) { var r = parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"), 10); U = document.body.style.paddingRight, document.body.style.paddingRight = r + n + "px"; } } V === void 0 && (V = document.body.style.overflow, document.body.style.overflow = "hidden"); }, q = function() { U !== void 0 && (document.body.style.paddingRight = U, U = void 0), V !== void 0 && (document.body.style.overflow = V, V = void 0); }, J = function() { return window.requestAnimationFrame(function() { if (H === void 0) { H = { position: document.body.style.position, top: document.body.style.top, left: document.body.style.left }; var e = window, t = e.scrollY, n = e.scrollX, r = e.innerHeight; document.body.style.position = "fixed", document.body.style.top = -t, document.body.style.left = -n, setTimeout(function() { return window.requestAnimationFrame(function() { var e = r - window.innerHeight; e && t >= r && (document.body.style.top = -(t + e)); }); }, 300); } }); }, oe = function() { if (H !== void 0) { var e = -parseInt(document.body.style.top, 10), t = -parseInt(document.body.style.left, 10); document.body.style.position = H.position, document.body.style.top = H.top, document.body.style.left = H.left, window.scrollTo(t, e), H = void 0; } }, se = function(e) { return e ? e.scrollHeight - e.scrollTop <= e.clientHeight : !1; }, ce = function(e, t) { var n = e.targetTouches[0].clientY - B; return W(e.target) ? !1 : t && t.scrollTop === 0 && n > 0 || se(t) && n < 0 ? G(e) : (e.stopPropagation(), !0); }, le = function(e, t) { if (!e) { console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices."); return; } if (!R.some(function(t) { return t.targetElement === e; })) { var n = { targetElement: e, options: t || {} }; R = [].concat(P(R), [n]), L ? J() : K(t), L && (e.ontouchstart = function(e) { e.targetTouches.length === 1 && (B = e.targetTouches[0].clientY); }, e.ontouchmove = function(t) { t.targetTouches.length === 1 && ce(t, e); }, z ||= (document.addEventListener("touchmove", G, F ? { passive: !1 } : void 0), !0)); } }, ue = function(e) { if (!e) { console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices."); return; } R = R.filter(function(t) { return t.targetElement !== e; }), L && (e.ontouchstart = null, e.ontouchmove = null, z && R.length === 0 && (document.removeEventListener("touchmove", G, F ? { passive: !1 } : void 0), z = !1)), L ? oe() : q(); }, Y = u({ name: "SidePanelCloseButton", emits: ["close"] }), de = [/* @__PURE__ */ a("span", { class: "vsp-close__x" }, null, -1)]; function fe(e, t, n, r, i, a) { return m(), S("div", { class: "vsp-close", onClick: t[0] ||= (t) => e.$emit("close") }, [...de]); } Y.render = fe, Y.__file = "src/components/SidePanelCloseButton.vue"; var X = u({ name: "VueSidePanel", components: { SidePanelCloseButton: Y }, props: { idName: { type: String, default: "vsp-container" }, hideCloseBtn: { type: Boolean, default: !1 }, noClose: { type: Boolean, default: !1 }, side: { type: String, validator: (e) => [ "top", "right", "bottom", "left" ].includes(e), default: "right" }, rerender: { type: Boolean, default: !1 }, zIndex: { type: [Number, String], default: "auto" }, width: { type: String, default: "auto" }, height: { type: String, default: "auto" }, lockScroll: { type: Boolean, default: !1 }, lockScrollHtml: { type: Boolean, default: !0 }, modelValue: { type: Boolean, default: !1, required: !0 }, overlayColor: { type: String, default: "black" }, overlayOpacity: { type: Number, default: .5 }, overlayDuration: { type: Number, default: 500 }, panelColor: { type: String, default: "white" }, panelDuration: { type: Number, default: 300 }, transitionName: { type: String, default: void 0 }, headerClass: { type: String, default: "" }, bodyClass: { type: String, default: "" }, footerClass: { type: String, default: "" } }, emits: [ "update:modelValue", "closed", "opened" ], setup(e, { emit: t, attrs: n }) { let r, i = g(null), a = g(null), o = g(null), c = g(null), l = g(null), u = g(0), p = g(0), m = g(0), h = g(0), _ = g(0), v = g(), y = g(!1), b = async () => { window?.innerHeight > 0 && (_.value = window.innerHeight), u.value = o.value ? o.value.clientHeight : 0, m.value = c.value ? c.value.clientHeight : 0, p.value = l.value ? l.value.scrollHeight : 0, h.value = i.value ? i.value.clientHeight : 0; }, x = () => t("update:modelValue", !1), S = (t, n) => { if (n) { setTimeout(() => { le(t, { reserveScrollBarGap: !0 }), e.lockScrollHtml && (document.documentElement.style.overflow = "hidden"); }, 0); return; } ue(t), e.lockScrollHtml && document.documentElement.style.removeProperty("overflow"); }, C = () => Math.max(...Array.from(document.querySelectorAll("body *"), (e) => parseFloat(window.getComputedStyle(e).zIndex)).filter((e) => !Number.isNaN(e)), 0); E(() => { v.value = e.zIndex === "auto" ? C() : e.zIndex; }), f(() => { document.getElementById(e.idName) || (r = document.createElement("div"), r.setAttribute("id", e.idName), document.body.appendChild(r)); }), ee(() => { let { modelValue: t, lockScroll: n } = e; n && i.value && t && S(i.value, !1), r && document.body.removeChild(r), window.removeEventListener("resize", b); }), w(() => [ c.value, o.value, e.height, e.width, e.side, e.modelValue ], () => { s(() => b()); }), w(() => [e.modelValue, i.value], (t, n) => { let r = n ? n[0] : !1, [i, a] = t, o = i, s = r && !i; if (a) { if (o && (y.value = !!document.body.style.overflow), i) { e.lockScroll && S(a, !0), b(), window.addEventListener("resize", b); return; } !e.lockScroll || !s || y.value || (setTimeout(() => { a && S(a, !1); }, e.panelDuration), window.removeEventListener("resize", b)); } }, { immediate: !0 }); let T = d(() => { if (!h.value) return; let t = p.value + m.value + u.value, n = h.value - m.value - u.value; return ["top", "bottom"].includes(e.side) && e.height === "auto" && (n = _.value >= t ? p.value : _.value - m.value - u.value), n; }); return { body: l, panel: i, overlay: a, overlayStyles: d(() => ({ zIndex: v.value, animationDuration: `${e.overlayDuration}ms`, "--overlay-opacity": e.overlayOpacity, opacity: e.modelValue ? e.overlayOpacity : 0, backgroundColor: e.overlayColor, pointerEvents: e.modelValue ? "all" : "none" })), header: c, footer: o, closePanel: x, panelStyles: d(() => ({ width: ["left", "right"].includes(e.side) ? e.width : void 0, maxWidth: "100%", ...["top", "bottom"].includes(e.side) ? { height: e.height, maxHeight: "100%" } : {}, zIndex: v.value, backgroundColor: e.panelColor, animationDuration: `${e.panelDuration}ms`, ...Object.assign({}, n.style) })), bodyHeight: T }; } }); function pe(e, t, o, s, u, d) { let f = ne("SidePanelCloseButton"); return m(), r(n, { to: `#${e.idName}` }, [a("div", { class: i(["vsp-wrapper", [e.modelValue && "vsp-wrapper--active"]]) }, [c(_, { name: "overlay", persisted: "" }, { default: v(() => [b(a("div", { ref: "overlay", class: "vsp-overlay", style: C(e.overlayStyles), onClick: t[0] ||= () => e.noClose ? void 0 : e.closePanel() }, null, 4), [[h, e.modelValue]])]), _: 1 }), c(_, { name: e.transitionName || `slide-${e.side}`, onAfterEnter: t[1] ||= (t) => e.$emit("opened"), onAfterLeave: t[2] ||= (t) => e.$emit("closed") }, { default: v(() => [!e.rerender || e.modelValue ? b((m(), S("div", { key: 0, ref: "panel", class: i(["vsp", [`vsp--${e.side}-side`, e.$attrs.class]]), style: C(e.panelStyles) }, [ e.$slots.header ? (m(), S("div", { key: 0, ref: "header", class: i([e.headerClass, "vsp__header"]) }, [y(e.$slots, "header", { close: e.closePanel })], 2)) : l("v-if", !0), a("div", { ref: "body", class: i([e.bodyClass, "vsp__body"]), style: C({ height: `${e.bodyHeight}px` }) }, [y(e.$slots, "default", { close: e.closePanel }), e.hideCloseBtn ? l("v-if", !0) : (m(), r(f, { key: 0, onClose: e.closePanel }, null, 8, ["onClose"]))], 6), e.$slots.footer ? (m(), S("div", { key: 1, ref: "footer", class: i([e.footerClass, "vsp__footer"]) }, [y(e.$slots, "footer")], 2)) : l("v-if", !0) ], 6)), [[h, e.rerender ? !0 : e.modelValue]]) : l("v-if", !0)]), _: 3 }, 8, ["name"])], 2)], 8, ["to"]); } X.render = pe, X.__file = "src/components/SidePanel.vue"; //#endregion //#region src/components/side-panels/Base.vue?vue&type=script&setup=true&lang.ts var me = { id: "konnectio-side-panel-header" }, he = { id: "konnectio-side-panel-title" }, ge = { key: 0, id: "konnectio-side-panel-subtitle" }, _e = ["innerHTML"], ve = /* @__PURE__ */ k(/* @__PURE__ */ u({ __name: "Base", props: { modelValue: { type: Boolean }, title: {}, subtitle: {}, idName: {}, description: {}, side: { default: "right" }, lockScroll: { type: Boolean, default: !0 }, hideCloseButton: { type: Boolean, default: !0 }, width: { default: "840px" } }, emits: [ "update:modelValue", "opened", "closed" ], setup(n, { emit: i }) { let s = i, u = d(() => { let e = navigator?.userAgentData?.platform || navigator?.platform; return (/iPad|iPhone|iPod/.test(e) || e === "MacIntel" && navigator.maxTouchPoints > 1) && !window.MSStream; }); function f() { s("closed"); } function p() { s("opened"); } return (i, s) => (m(), r(o(X), { modelValue: n.modelValue, "lock-scroll": !u.value && n.lockScroll, "hide-close-btn": n.hideCloseButton, width: n.width, "onUpdate:modelValue": s[1] ||= (e) => i.$emit("update:modelValue", e), onClosed: f, onOpened: p }, e({ header: v(() => [a("div", me, [a("h2", he, [a("span", null, t(o(ie)(n.title)), 1), a("button", { id: "konnectio-side-panel-close", onClick: s[0] ||= (e) => i.$emit("update:modelValue", !1) }, [c(N, { icon: "times", type: "fas", color: "header" })])]), n.subtitle ? (m(), S("h4", ge, [a("span", null, t(n.subtitle), 1)])) : l("", !0)])]), default: v(() => [n.description ? (m(), S("div", { key: 0, class: "konnectio-side-panel-description", innerHTML: n.description }, null, 8, _e)) : l("", !0), y(i.$slots, "default", {}, void 0, !0)]), _: 2 }, [i.$slots.footer ? { name: "footer", fn: v(() => [y(i.$slots, "footer", {}, void 0, !0)]), key: "0" } : void 0]), 1032, [ "modelValue", "lock-scroll", "hide-close-btn", "width" ])); } }), [["__scopeId", "data-v-c84b8ee2"]]), ye = { class: "konnectio-phone-input" }, be = /* @__PURE__ */ k(/* @__PURE__ */ u({ __name: "PhoneField", props: { modelValue: {}, label: {}, id: {}, placeholder: {}, icon: { default: "phone-office" }, iconColor: {}, iconType: { default: "fal" }, required: { type: Boolean, default: !1 }, readonly: { type: Boolean, default: !1 } }, emits: ["update:modelValue"], setup(e, { emit: t }) { let n = t, i = e, s = i.id || A(), l = g("+45"), u = g(""); function d() { n("update:modelValue", `${l.value} ${u.value}`); } return E(() => { if (i.modelValue) { let e = i.modelValue.split(" "); l.value = e[0], u.value = e[1]; } }), (t, n) => (m(), r(j, { label: e.label, id: o(s), type: "phone", required: e.required, readonly: e.readonly }, { default: v(() => [a("div", ye, [c(M, { modelValue: l.value, "onUpdate:modelValue": n[0] ||= (e) => l.value = e, type: "text", id: o(A)(), name: "phone-code", autocomplete: "tel-country-code", icon: e.icon, "icon-color": e.iconColor, "icon-type": e.iconType, placeholder: "+XX", required: e.required, readonly: e.readonly, onInput: n[1] ||= (e) => d() }, null, 8, [ "modelValue", "id", "icon", "icon-color", "icon-type", "required", "readonly" ]), c(M, { modelValue: u.value, "onUpdate:modelValue": n[2] ||= (e) => u.value = e, type: "number", name: "phone", autocomplete: "tel-national", inputmode: "numeric", id: o(s), placeholder: e.placeholder, required: e.required, readonly: e.readonly, onInput: n[3] ||= (e) => d() }, null, 8, [ "modelValue", "id", "placeholder", "required", "readonly" ])])]), _: 1 }, 8, [ "label", "id", "required", "readonly" ])); } }), [["__scopeId", "data-v-3e373d03"]]), xe = [ "required", "type", "name", "readonly", "disabled", "value", "checked" ], Se = ["data-test"], Z = { key: 0 }, Ce = { key: 1, class: /* @__PURE__ */ i(["konnectio-click-box-label", "inline"]) }, we = /* @__PURE__ */ k(/* @__PURE__ */ u({ __name: "Checkbox", props: { modelValue: { type: [ String, Boolean, Number ] }, numeric: { type: Boolean, default: !1 }, checked: { type: Boolean, default: !1 }, label: {}, price: {}, name: {}, readonly: { type: Boolean, default: !1 }, type: { default: "checkbox" }, required: { type: Boolean, default: !1 }, val: {} }, emits: ["update:modelValue"], setup(e, { emit: n }) { let s = e, c = n, u = te(); function d() { s.readonly !== !0 && c("update:modelValue", s.type === "radio" ? s.val : s.numeric ? +!s.modelValue : !s.modelValue); } return (n, s) => (m(), r(j, { required: e.required, type: e.type, readonly: e.readonly }, { default: v(() => [a("label", { class: i([ "konnectio-click-box-container", { "is-readonly": e.readonly }, { "has-label": e.label || o(u).default }, e.type === "radio" ? "radio" : "checkbox", { active: e.type === "radio" ? e.val === e.modelValue : !!e.modelValue } ]) }, [ a("input", p(n.$attrs, { required: !!e.required, type: e.type, name: e.name, class: "hidden", readonly: !!e.readonly, disabled: !!e.readonly, value: e.type === "radio" ? e.val : e.modelValue, checked: e.type === "radio" ? e.val === e.modelValue : !!e.modelValue, onChange: s[0] ||= (e) => d() }), null, 16, xe), a("div", { class: i(["konnectio-click-box", { checked: e.type === "radio" ? e.val === e.modelValue : !!e.modelValue }]), tabindex: "0", "data-test": e.name, onKeyup: s[1] ||= D((e) => d(), ["enter"]) }, null, 42, Se), e.label ? (m(), S("div", { key: 0, class: i([ "konnectio-click-box-label", "text-hover", { "with-price": e.price } ]) }, [a("span", null, t(e.label), 1), e.price ? (m(), S("span", Z, t(e.price), 1)) : l("", !0)], 2)) : o(u).default ? (m(), S("div", Ce, [y(n.$slots, "default", {}, void 0, !0)])) : l("", !0) ], 2)]), _: 3 }, 8, [ "required", "type", "readonly" ])); } }), [["__scopeId", "data-v-673fba05"]]), Te = { href: "https://policies.google.com/privacy", target: "_blank" }, Ee = { href: "https://policies.google.com/terms", target: "_blank" }, Q = /* @__PURE__ */ u({ __name: "GoogleNotice", setup(e) { let { t: n } = T(); return (e, r) => (m(), S("span", null, [ x(t(o(n)("googleNotice")) + " ", 1), a("a", Te, t(o(n)("googlePrivacyPolicy")), 1), x(" " + t(o(n)("googleAnd")) + " ", 1), a("a", Ee, t(o(n)("googleTOS")), 1), x(" " + t(o(n)("googleApply")) + ". ", 1) ])); } }); //#endregion //#region src/components/GoogleNotice.vue?vue&type=i18n&index=0&lang.yaml function $(e) { let t = e; t.__i18n = t.__i18n || [], t.__i18n.push({ locale: "", resource: { da: { googleNotice: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Denne side er beskyttet af reCAPTCHA og Google's" } }, googlePrivacyPolicy: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Privatlivspolitik" } }, googleAnd: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "og" } }, googleTOS: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Servicevilkår" } }, googleApply: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "er gældende" } } }, en: { googleNotice: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "This site is protected by reCAPTCHA and the Google" } }, googlePrivacyPolicy: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Privacy Policy" } }, googleAnd: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "and" } }, googleTOS: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "Terms of Service" } }, googleApply: { t: 0, b: { t: 2, i: [{ t: 3 }], s: "apply" } } } } }); } //#endregion //#region src/components/GoogleNotice.vue typeof $ == "function" && $(Q); var De = Q, Oe = /* @__PURE__ */ k(/* @__PURE__ */ u({ __name: "CheckoutWindow", setup(e) { let { paymentGatewayId: t } = re(O()); return E(() => { let e = document.createElement("script"), t = document.createElement("script"); e.setAttribute("src", "https://checkout.dibspayment.eu/v1/checkout.js?v=1"), t.setAttribute("src", "https://checkout.reepay.com/checkout.js"), document.head.appendChild(e), document.head.appendChild(t); }), (e, n) => (m(), S("div", null, [a("div", { id: "konnectio-payment-checkout-wrapper", class: i({ reePay: o(t) === o(ae).ReePay }) }, [...n[0] ||= [a("div", { id: "konnectio-payment-checkout" }, null, -1)]], 2)])); } }), [["__scopeId", "data-v-403e3fbf"]]); //#endregion export { ve as a, be as i, De as n, we as r, Oe as t };