UNPKG

@dotcms/analytics

Version:

Official JavaScript library for Content Analytics with DotCMS.

82 lines (81 loc) 2.73 kB
import "../../internal/constants.js"; function C(t) { return t.map((a) => { const o = a.getBoundingClientRect(), n = Array.from( a.querySelectorAll('[data-dot-object="contentlet"]') ); return { x: o.x, y: o.y, width: o.width, height: o.height, payload: JSON.stringify({ container: u(a) }), contentlets: f(o, n) }; }); } function f(t, a) { return a.map((o) => { var d, r, i, e, s, c; const n = o.getBoundingClientRect(); return { x: 0, y: n.y - t.y, width: n.width, height: n.height, payload: JSON.stringify({ container: (d = o.dataset) != null && d.dotContainer ? JSON.parse((r = o.dataset) == null ? void 0 : r.dotContainer) : y(o), contentlet: { identifier: (i = o.dataset) == null ? void 0 : i.dotIdentifier, title: (e = o.dataset) == null ? void 0 : e.dotTitle, inode: (s = o.dataset) == null ? void 0 : s.dotInode, contentType: (c = o.dataset) == null ? void 0 : c.dotType } }) }; }); } function u(t) { var a, o, n, d; return { acceptTypes: ((a = t.dataset) == null ? void 0 : a.dotAcceptTypes) || "", identifier: ((o = t.dataset) == null ? void 0 : o.dotIdentifier) || "", maxContentlets: ((n = t.dataset) == null ? void 0 : n.maxContentlets) || "", uuid: ((d = t.dataset) == null ? void 0 : d.dotUuid) || "" }; } function y(t) { const a = t.closest('[data-dot-object="container"]'); return a ? u(a) : (console.warn("No container found for the contentlet"), null); } function g(t) { var o, n, d; if (!t) return null; const a = t.querySelector('[data-dot-object="empty-content"]'); return ((o = t == null ? void 0 : t.dataset) == null ? void 0 : o.dotObject) === "contentlet" || // The container inside Headless components have a span with the data-dot-object="container" attribute ((n = t == null ? void 0 : t.dataset) == null ? void 0 : n.dotObject) === "container" && a || // The container inside Traditional have no content inside ((d = t == null ? void 0 : t.dataset) == null ? void 0 : d.dotObject) === "container" && t.children.length === 0 ? t : g(t == null ? void 0 : t.parentElement); } function h(t) { const a = t.querySelectorAll( '[data-dot-object="vtl-file"]' ); return a.length ? Array.from(a).map((o) => { var n, d; return { inode: (n = o.dataset) == null ? void 0 : n.dotInode, name: (d = o.dataset) == null ? void 0 : d.dotUrl }; }) : null; } export { g as findDotCMSElement, h as findDotCMSVTLData, y as getClosestDotCMSContainerData, u as getDotCMSContainerData, f as getDotCMSContentletsBound, C as getDotCMSPageBounds };