UNPKG

@govbr-ds/webcomponents

Version:

Biblioteca de Web Components baseado no GovBR-DS

1,717 lines (1,598 loc) 47.4 kB
/*! * Construído por SERPRO * © https://serpro.gov.br/ - MIT License. */ import { _ as t } from "./p-DIPMDb5E.js"; /** * Custom positioning reference element. * @see https://floating-ui.com/docs/virtual-elements */ const e = [ "top", "right", "bottom", "left" ]; const n = Math.min; const o = Math.max; const i = Math.round; const s = Math.floor; const createCoords = t => ({ x: t, y: t }); const r = { left: "right", right: "left", bottom: "top", top: "bottom" }; const c = { start: "end", end: "start" }; function clamp(t, e, i) { return o(t, n(e, i)); } function evaluate(t, e) { return typeof t === "function" ? t(e) : t; } function getSide(t) { return t.split("-")[0]; } function getAlignment(t) { return t.split("-")[1]; } function getOppositeAxis(t) { return t === "x" ? "y" : "x"; } function getAxisLength(t) { return t === "y" ? "height" : "width"; } const l = new Set([ "top", "bottom" ]); function getSideAxis(t) { return l.has(getSide(t)) ? "y" : "x"; } function getAlignmentAxis(t) { return getOppositeAxis(getSideAxis(t)); } function getAlignmentSides(t, e, n) { if (n === void 0) { n = false; } const o = getAlignment(t); const i = getAlignmentAxis(t); const s = getAxisLength(i); let r = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top"; if (e.reference[s] > e.floating[s]) { r = getOppositePlacement(r); } return [ r, getOppositePlacement(r) ]; } function getExpandedPlacements(t) { const e = getOppositePlacement(t); return [ getOppositeAlignmentPlacement(t), e, getOppositeAlignmentPlacement(e) ]; } function getOppositeAlignmentPlacement(t) { return t.replace(/start|end/g, (t => c[t])); } const a = [ "left", "right" ]; const f = [ "right", "left" ]; const u = [ "top", "bottom" ]; const d = [ "bottom", "top" ]; function getSideList(t, e, n) { switch (t) { case "top": case "bottom": if (n) return e ? f : a; return e ? a : f; case "left": case "right": return e ? u : d; default: return []; } } function getOppositeAxisPlacements(t, e, n, o) { const i = getAlignment(t); let s = getSideList(getSide(t), n === "start", o); if (i) { s = s.map((t => t + "-" + i)); if (e) { s = s.concat(s.map(getOppositeAlignmentPlacement)); } } return s; } function getOppositePlacement(t) { return t.replace(/left|right|bottom|top/g, (t => r[t])); } function expandPaddingObject(t) { return { top: 0, right: 0, bottom: 0, left: 0, ...t }; } function getPaddingObject(t) { return typeof t !== "number" ? expandPaddingObject(t) : { top: t, right: t, bottom: t, left: t }; } function rectToClientRect(t) { const {x: e, y: n, width: o, height: i} = t; return { width: o, height: i, top: n, left: e, right: e + o, bottom: n + i, x: e, y: n }; } function computeCoordsFromPlacement(t, e, n) { let {reference: o, floating: i} = t; const s = getSideAxis(e); const r = getAlignmentAxis(e); const c = getAxisLength(r); const l = getSide(e); const a = s === "y"; const f = o.x + o.width / 2 - i.width / 2; const u = o.y + o.height / 2 - i.height / 2; const d = o[c] / 2 - i[c] / 2; let g; switch (l) { case "top": g = { x: f, y: o.y - i.height }; break; case "bottom": g = { x: f, y: o.y + o.height }; break; case "right": g = { x: o.x + o.width, y: u }; break; case "left": g = { x: o.x - i.width, y: u }; break; default: g = { x: o.x, y: o.y }; } switch (getAlignment(e)) { case "start": g[r] -= d * (n && a ? -1 : 1); break; case "end": g[r] += d * (n && a ? -1 : 1); break; } return g; } /** * Computes the `x` and `y` coordinates that will place the floating element * next to a given reference element. * * This export does not have any `platform` interface logic. You will need to * write one for the platform you are using Floating UI with. */ const computePosition$1 = async (t, e, n) => { const {placement: o = "bottom", strategy: i = "absolute", middleware: s = [], platform: r} = n; const c = s.filter(Boolean); const l = await (r.isRTL == null ? void 0 : r.isRTL(e)); let a = await r.getElementRects({ reference: t, floating: e, strategy: i }); let {x: f, y: u} = computeCoordsFromPlacement(a, o, l); let d = o; let g = {}; let m = 0; for (let n = 0; n < c.length; n++) { const {name: s, fn: p} = c[n]; const {x: h, y: w, data: y, reset: v} = await p({ x: f, y: u, initialPlacement: o, placement: d, strategy: i, middlewareData: g, rects: a, platform: r, elements: { reference: t, floating: e } }); f = h != null ? h : f; u = w != null ? w : u; g = { ...g, [s]: { ...g[s], ...y } }; if (v && m <= 50) { m++; if (typeof v === "object") { if (v.placement) { d = v.placement; } if (v.rects) { a = v.rects === true ? await r.getElementRects({ reference: t, floating: e, strategy: i }) : v.rects; } ({x: f, y: u} = computeCoordsFromPlacement(a, d, l)); } n = -1; } } return { x: f, y: u, placement: d, strategy: i, middlewareData: g }; }; /** * Resolves with an object of overflow side offsets that determine how much the * element is overflowing a given clipping boundary on each side. * - positive = overflowing the boundary by that number of pixels * - negative = how many pixels left before it will overflow * - 0 = lies flush with the boundary * @see https://floating-ui.com/docs/detectOverflow */ async function detectOverflow(t, e) { var n; if (e === void 0) { e = {}; } const {x: o, y: i, platform: s, rects: r, elements: c, strategy: l} = t; const {boundary: a = "clippingAncestors", rootBoundary: f = "viewport", elementContext: u = "floating", altBoundary: d = false, padding: g = 0} = evaluate(e, t); const m = getPaddingObject(g); const p = u === "floating" ? "reference" : "floating"; const h = c[d ? p : u]; const w = rectToClientRect(await s.getClippingRect({ element: ((n = await (s.isElement == null ? void 0 : s.isElement(h))) != null ? n : true) ? h : h.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(c.floating)), boundary: a, rootBoundary: f, strategy: l })); const y = u === "floating" ? { x: o, y: i, width: r.floating.width, height: r.floating.height } : r.reference; const v = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c.floating)); const x = await (s.isElement == null ? void 0 : s.isElement(v)) ? await (s.getScale == null ? void 0 : s.getScale(v)) || { x: 1, y: 1 } : { x: 1, y: 1 }; const b = rectToClientRect(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({ elements: c, rect: y, offsetParent: v, strategy: l }) : y); return { top: (w.top - b.top + m.top) / x.y, bottom: (b.bottom - w.bottom + m.bottom) / x.y, left: (w.left - b.left + m.left) / x.x, right: (b.right - w.right + m.right) / x.x }; } /** * Provides data to position an inner element of the floating element so that it * appears centered to the reference element. * @see https://floating-ui.com/docs/arrow */ const arrow$1 = t => ({ name: "arrow", options: t, async fn(e) { const {x: o, y: i, placement: s, rects: r, platform: c, elements: l, middlewareData: a} = e; // Since `element` is required, we don't Partial<> the type. const {element: f, padding: u = 0} = evaluate(t, e) || {}; if (f == null) { return {}; } const d = getPaddingObject(u); const g = { x: o, y: i }; const m = getAlignmentAxis(s); const p = getAxisLength(m); const h = await c.getDimensions(f); const w = m === "y"; const y = w ? "top" : "left"; const v = w ? "bottom" : "right"; const x = w ? "clientHeight" : "clientWidth"; const b = r.reference[p] + r.reference[m] - g[m] - r.floating[p]; const S = g[m] - r.reference[m]; const A = await (c.getOffsetParent == null ? void 0 : c.getOffsetParent(f)); let O = A ? A[x] : 0; // DOM platform can return `window` as the `offsetParent`. if (!O || !await (c.isElement == null ? void 0 : c.isElement(A))) { O = l.floating[x] || r.floating[p]; } const C = b / 2 - S / 2; // If the padding is large enough that it causes the arrow to no longer be // centered, modify the padding so that it is centered. const E = O / 2 - h[p] / 2 - 1; const P = n(d[y], E); const R = n(d[v], E); // Make sure the arrow doesn't overflow the floating element if the center // point is outside the floating element's bounds. const T = P; const L = O - h[p] - R; const N = O / 2 - h[p] / 2 + C; const F = clamp(T, N, L); // If the reference is small enough that the arrow's padding causes it to // to point to nothing for an aligned placement, adjust the offset of the // floating element itself. To ensure `shift()` continues to take action, // a single reset is performed when this is true. const D = !a.arrow && getAlignment(s) != null && N !== F && r.reference[p] / 2 - (N < T ? P : R) - h[p] / 2 < 0; const W = D ? N < T ? N - T : N - L : 0; return { [m]: g[m] + W, data: { [m]: F, centerOffset: N - F - W, ...D && { alignmentOffset: W } }, reset: D }; } }) /** * Optimizes the visibility of the floating element by flipping the `placement` * in order to keep it in view when the preferred placement(s) will overflow the * clipping boundary. Alternative to `autoPlacement`. * @see https://floating-ui.com/docs/flip */; const flip$1 = function(t) { if (t === void 0) { t = {}; } return { name: "flip", options: t, async fn(e) { var n, o; const {placement: i, middlewareData: s, rects: r, initialPlacement: c, platform: l, elements: a} = e; const {mainAxis: f = true, crossAxis: u = true, fallbackPlacements: d, fallbackStrategy: g = "bestFit", fallbackAxisSideDirection: m = "none", flipAlignment: p = true, ...h} = evaluate(t, e); // If a reset by the arrow was caused due to an alignment offset being // added, we should skip any logic now since `flip()` has already done its // work. // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643 if ((n = s.arrow) != null && n.alignmentOffset) { return {}; } const w = getSide(i); const y = getSideAxis(c); const v = getSide(c) === c; const x = await (l.isRTL == null ? void 0 : l.isRTL(a.floating)); const b = d || (v || !p ? [ getOppositePlacement(c) ] : getExpandedPlacements(c)); const S = m !== "none"; if (!d && S) { b.push(...getOppositeAxisPlacements(c, p, m, x)); } const A = [ c, ...b ]; const O = await detectOverflow(e, h); const C = []; let E = ((o = s.flip) == null ? void 0 : o.overflows) || []; if (f) { C.push(O[w]); } if (u) { const t = getAlignmentSides(i, r, x); C.push(O[t[0]], O[t[1]]); } E = [ ...E, { placement: i, overflows: C } ]; // One or more sides is overflowing. if (!C.every((t => t <= 0))) { var P, R; const t = (((P = s.flip) == null ? void 0 : P.index) || 0) + 1; const e = A[t]; if (e) { const n = u === "alignment" ? y !== getSideAxis(e) : false; if (!n || // We leave the current main axis only if every placement on that axis // overflows the main axis. E.every((t => getSideAxis(t.placement) === y ? t.overflows[0] > 0 : true))) { // Try next placement and re-run the lifecycle. return { data: { index: t, overflows: E }, reset: { placement: e } }; } } // First, find the candidates that fit on the mainAxis side of overflow, // then find the placement that fits the best on the main crossAxis side. let n = (R = E.filter((t => t.overflows[0] <= 0)).sort(((t, e) => t.overflows[1] - e.overflows[1]))[0]) == null ? void 0 : R.placement; // Otherwise fallback. if (!n) { switch (g) { case "bestFit": { var T; const t = (T = E.filter((t => { if (S) { const e = getSideAxis(t.placement); return e === y || // Create a bias to the `y` side axis due to horizontal // reading directions favoring greater width. e === "y"; } return true; })).map((t => [ t.placement, t.overflows.filter((t => t > 0)).reduce(((t, e) => t + e), 0) ])).sort(((t, e) => t[1] - e[1]))[0]) == null ? void 0 : T[0]; if (t) { n = t; } break; } case "initialPlacement": n = c; break; } } if (i !== n) { return { reset: { placement: n } }; } } return {}; } }; }; function getSideOffsets(t, e) { return { top: t.top - e.height, right: t.right - e.width, bottom: t.bottom - e.height, left: t.left - e.width }; } function isAnySideFullyClipped(t) { return e.some((e => t[e] >= 0)); } /** * Provides data to hide the floating element in applicable situations, such as * when it is not in the same clipping context as the reference element. * @see https://floating-ui.com/docs/hide */ const hide$1 = function(t) { if (t === void 0) { t = {}; } return { name: "hide", options: t, async fn(e) { const {rects: n} = e; const {strategy: o = "referenceHidden", ...i} = evaluate(t, e); switch (o) { case "referenceHidden": { const t = await detectOverflow(e, { ...i, elementContext: "reference" }); const o = getSideOffsets(t, n.reference); return { data: { referenceHiddenOffsets: o, referenceHidden: isAnySideFullyClipped(o) } }; } case "escaped": { const t = await detectOverflow(e, { ...i, altBoundary: true }); const o = getSideOffsets(t, n.floating); return { data: { escapedOffsets: o, escaped: isAnySideFullyClipped(o) } }; } default: { return {}; } } } }; }; const g = new Set([ "left", "top" ]); // For type backwards-compatibility, the `OffsetOptions` type was also // Derivable. async function convertValueToCoords(t, e) { const {placement: n, platform: o, elements: i} = t; const s = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)); const r = getSide(n); const c = getAlignment(n); const l = getSideAxis(n) === "y"; const a = g.has(r) ? -1 : 1; const f = s && l ? -1 : 1; const u = evaluate(e, t); // eslint-disable-next-line prefer-const let {mainAxis: d, crossAxis: m, alignmentAxis: p} = typeof u === "number" ? { mainAxis: u, crossAxis: 0, alignmentAxis: null } : { mainAxis: u.mainAxis || 0, crossAxis: u.crossAxis || 0, alignmentAxis: u.alignmentAxis }; if (c && typeof p === "number") { m = c === "end" ? p * -1 : p; } return l ? { x: m * f, y: d * a } : { x: d * a, y: m * f }; } /** * Modifies the placement by translating the floating element along the * specified axes. * A number (shorthand for `mainAxis` or distance), or an axes configuration * object may be passed. * @see https://floating-ui.com/docs/offset */ const offset$1 = function(t) { if (t === void 0) { t = 0; } return { name: "offset", options: t, async fn(e) { var n, o; const {x: i, y: s, placement: r, middlewareData: c} = e; const l = await convertValueToCoords(e, t); // If the placement is the same and the arrow caused an alignment offset // then we don't need to change the positioning coordinates. if (r === ((n = c.offset) == null ? void 0 : n.placement) && (o = c.arrow) != null && o.alignmentOffset) { return {}; } return { x: i + l.x, y: s + l.y, data: { ...l, placement: r } }; } }; }; /** * Optimizes the visibility of the floating element by shifting it in order to * keep it in view when it will overflow the clipping boundary. * @see https://floating-ui.com/docs/shift */ const shift$1 = function(t) { if (t === void 0) { t = {}; } return { name: "shift", options: t, async fn(e) { const {x: n, y: o, placement: i} = e; const {mainAxis: s = true, crossAxis: r = false, limiter: c = { fn: t => { let {x: e, y: n} = t; return { x: e, y: n }; } }, ...l} = evaluate(t, e); const a = { x: n, y: o }; const f = await detectOverflow(e, l); const u = getSideAxis(getSide(i)); const d = getOppositeAxis(u); let g = a[d]; let m = a[u]; if (s) { const t = d === "y" ? "top" : "left"; const e = d === "y" ? "bottom" : "right"; const n = g + f[t]; const o = g - f[e]; g = clamp(n, g, o); } if (r) { const t = u === "y" ? "top" : "left"; const e = u === "y" ? "bottom" : "right"; const n = m + f[t]; const o = m - f[e]; m = clamp(n, m, o); } const p = c.fn({ ...e, [d]: g, [u]: m }); return { ...p, data: { x: p.x - n, y: p.y - o, enabled: { [d]: s, [u]: r } } }; } }; }; function hasWindow() { return typeof window !== "undefined"; } function getNodeName(t) { if (isNode(t)) { return (t.nodeName || "").toLowerCase(); } // Mocked nodes in testing environments may not be instances of Node. By // returning `#document` an infinite loop won't occur. // https://github.com/floating-ui/floating-ui/issues/2317 return "#document"; } function getWindow(t) { var e; return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window; } function getDocumentElement(t) { var e; return (e = (isNode(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement; } function isNode(t) { if (!hasWindow()) { return false; } return t instanceof Node || t instanceof getWindow(t).Node; } function isElement(t) { if (!hasWindow()) { return false; } return t instanceof Element || t instanceof getWindow(t).Element; } function isHTMLElement(t) { if (!hasWindow()) { return false; } return t instanceof HTMLElement || t instanceof getWindow(t).HTMLElement; } function isShadowRoot(t) { if (!hasWindow() || typeof ShadowRoot === "undefined") { return false; } return t instanceof ShadowRoot || t instanceof getWindow(t).ShadowRoot; } const m = new Set([ "inline", "contents" ]); function isOverflowElement(t) { const {overflow: e, overflowX: n, overflowY: o, display: i} = getComputedStyle$1(t); return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !m.has(i); } const p = new Set([ "table", "td", "th" ]); function isTableElement(t) { return p.has(getNodeName(t)); } const h = [ ":popover-open", ":modal" ]; function isTopLayer(t) { return h.some((e => { try { return t.matches(e); } catch (t) { return false; } })); } const w = [ "transform", "translate", "scale", "rotate", "perspective" ]; const y = [ "transform", "translate", "scale", "rotate", "perspective", "filter" ]; const v = [ "paint", "layout", "strict", "content" ]; function isContainingBlock(t) { const e = isWebKit(); const n = isElement(t) ? getComputedStyle$1(t) : t; // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block // https://drafts.csswg.org/css-transforms-2/#individual-transforms return w.some((t => n[t] ? n[t] !== "none" : false)) || (n.containerType ? n.containerType !== "normal" : false) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : false) || !e && (n.filter ? n.filter !== "none" : false) || y.some((t => (n.willChange || "").includes(t))) || v.some((t => (n.contain || "").includes(t))); } function getContainingBlock(t) { let e = getParentNode(t); while (isHTMLElement(e) && !isLastTraversableNode(e)) { if (isContainingBlock(e)) { return e; } else if (isTopLayer(e)) { return null; } e = getParentNode(e); } return null; } function isWebKit() { if (typeof CSS === "undefined" || !CSS.supports) return false; return CSS.supports("-webkit-backdrop-filter", "none"); } const x = new Set([ "html", "body", "#document" ]); function isLastTraversableNode(t) { return x.has(getNodeName(t)); } function getComputedStyle$1(t) { return getWindow(t).getComputedStyle(t); } function getNodeScroll(t) { if (isElement(t)) { return { scrollLeft: t.scrollLeft, scrollTop: t.scrollTop }; } return { scrollLeft: t.scrollX, scrollTop: t.scrollY }; } function getParentNode(t) { if (getNodeName(t) === "html") { return t; } const e = // Step into the shadow DOM of the parent of a slotted node. t.assignedSlot || // DOM Element detected. t.parentNode || // ShadowRoot detected. isShadowRoot(t) && t.host || // Fallback. getDocumentElement(t); return isShadowRoot(e) ? e.host : e; } function getNearestOverflowAncestor(t) { const e = getParentNode(t); if (isLastTraversableNode(e)) { return t.ownerDocument ? t.ownerDocument.body : t.body; } if (isHTMLElement(e) && isOverflowElement(e)) { return e; } return getNearestOverflowAncestor(e); } function getOverflowAncestors(t, e, n) { var o; if (e === void 0) { e = []; } if (n === void 0) { n = true; } const i = getNearestOverflowAncestor(t); const s = i === ((o = t.ownerDocument) == null ? void 0 : o.body); const r = getWindow(i); if (s) { const t = getFrameElement(r); return e.concat(r, r.visualViewport || [], isOverflowElement(i) ? i : [], t && n ? getOverflowAncestors(t) : []); } return e.concat(i, getOverflowAncestors(i, [], n)); } function getFrameElement(t) { return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null; } function getCssDimensions(t) { const e = getComputedStyle$1(t); // In testing environments, the `width` and `height` properties are empty // strings for SVG elements, returning NaN. Fallback to `0` in this case. let n = parseFloat(e.width) || 0; let o = parseFloat(e.height) || 0; const s = isHTMLElement(t); const r = s ? t.offsetWidth : n; const c = s ? t.offsetHeight : o; const l = i(n) !== r || i(o) !== c; if (l) { n = r; o = c; } return { width: n, height: o, $: l }; } function unwrapElement(t) { return !isElement(t) ? t.contextElement : t; } function getScale(t) { const e = unwrapElement(t); if (!isHTMLElement(e)) { return createCoords(1); } const n = e.getBoundingClientRect(); const {width: o, height: s, $: r} = getCssDimensions(e); let c = (r ? i(n.width) : n.width) / o; let l = (r ? i(n.height) : n.height) / s; // 0, NaN, or Infinity should always fallback to 1. if (!c || !Number.isFinite(c)) { c = 1; } if (!l || !Number.isFinite(l)) { l = 1; } return { x: c, y: l }; } const b = createCoords(0); function getVisualOffsets(t) { const e = getWindow(t); if (!isWebKit() || !e.visualViewport) { return b; } return { x: e.visualViewport.offsetLeft, y: e.visualViewport.offsetTop }; } function shouldAddVisualOffsets(t, e, n) { if (e === void 0) { e = false; } if (!n || e && n !== getWindow(t)) { return false; } return e; } function getBoundingClientRect(t, e, n, o) { if (e === void 0) { e = false; } if (n === void 0) { n = false; } const i = t.getBoundingClientRect(); const s = unwrapElement(t); let r = createCoords(1); if (e) { if (o) { if (isElement(o)) { r = getScale(o); } } else { r = getScale(t); } } const c = shouldAddVisualOffsets(s, n, o) ? getVisualOffsets(s) : createCoords(0); let l = (i.left + c.x) / r.x; let a = (i.top + c.y) / r.y; let f = i.width / r.x; let u = i.height / r.y; if (s) { const t = getWindow(s); const e = o && isElement(o) ? getWindow(o) : o; let n = t; let i = getFrameElement(n); while (i && o && e !== n) { const t = getScale(i); const e = i.getBoundingClientRect(); const o = getComputedStyle$1(i); const s = e.left + (i.clientLeft + parseFloat(o.paddingLeft)) * t.x; const r = e.top + (i.clientTop + parseFloat(o.paddingTop)) * t.y; l *= t.x; a *= t.y; f *= t.x; u *= t.y; l += s; a += r; n = getWindow(i); i = getFrameElement(n); } } return rectToClientRect({ width: f, height: u, x: l, y: a }); } // If <html> has a CSS width greater than the viewport, then this will be // incorrect for RTL. function getWindowScrollBarX(t, e) { const n = getNodeScroll(t).scrollLeft; if (!e) { return getBoundingClientRect(getDocumentElement(t)).left + n; } return e.left + n; } function getHTMLOffset(t, e) { const n = t.getBoundingClientRect(); const o = n.left + e.scrollLeft - getWindowScrollBarX(t, n); const i = n.top + e.scrollTop; return { x: o, y: i }; } function convertOffsetParentRelativeRectToViewportRelativeRect(t) { let {elements: e, rect: n, offsetParent: o, strategy: i} = t; const s = i === "fixed"; const r = getDocumentElement(o); const c = e ? isTopLayer(e.floating) : false; if (o === r || c && s) { return n; } let l = { scrollLeft: 0, scrollTop: 0 }; let a = createCoords(1); const f = createCoords(0); const u = isHTMLElement(o); if (u || !u && !s) { if (getNodeName(o) !== "body" || isOverflowElement(r)) { l = getNodeScroll(o); } if (isHTMLElement(o)) { const t = getBoundingClientRect(o); a = getScale(o); f.x = t.x + o.clientLeft; f.y = t.y + o.clientTop; } } const d = r && !u && !s ? getHTMLOffset(r, l) : createCoords(0); return { width: n.width * a.x, height: n.height * a.y, x: n.x * a.x - l.scrollLeft * a.x + f.x + d.x, y: n.y * a.y - l.scrollTop * a.y + f.y + d.y }; } function getClientRects(t) { return Array.from(t.getClientRects()); } // Gets the entire size of the scrollable document area, even extending outside // of the `<html>` and `<body>` rect bounds if horizontally scrollable. function getDocumentRect(t) { const e = getDocumentElement(t); const n = getNodeScroll(t); const i = t.ownerDocument.body; const s = o(e.scrollWidth, e.clientWidth, i.scrollWidth, i.clientWidth); const r = o(e.scrollHeight, e.clientHeight, i.scrollHeight, i.clientHeight); let c = -n.scrollLeft + getWindowScrollBarX(t); const l = -n.scrollTop; if (getComputedStyle$1(i).direction === "rtl") { c += o(e.clientWidth, i.clientWidth) - s; } return { width: s, height: r, x: c, y: l }; } // Safety check: ensure the scrollbar space is reasonable in case this // calculation is affected by unusual styles. // Most scrollbars leave 15-18px of space. const S = 25; function getViewportRect(t, e) { const n = getWindow(t); const o = getDocumentElement(t); const i = n.visualViewport; let s = o.clientWidth; let r = o.clientHeight; let c = 0; let l = 0; if (i) { s = i.width; r = i.height; const t = isWebKit(); if (!t || t && e === "fixed") { c = i.offsetLeft; l = i.offsetTop; } } const a = getWindowScrollBarX(o); // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the // visual width of the <html> but this is not considered in the size // of `html.clientWidth`. if (a <= 0) { const t = o.ownerDocument; const e = t.body; const n = getComputedStyle(e); const i = t.compatMode === "CSS1Compat" ? parseFloat(n.marginLeft) + parseFloat(n.marginRight) || 0 : 0; const r = Math.abs(o.clientWidth - e.clientWidth - i); if (r <= S) { s -= r; } } else if (a <= S) { // If the <body> scrollbar is on the left, the width needs to be extended // by the scrollbar amount so there isn't extra space on the right. s += a; } return { width: s, height: r, x: c, y: l }; } const A = new Set([ "absolute", "fixed" ]); // Returns the inner client rect, subtracting scrollbars if present. function getInnerBoundingClientRect(t, e) { const n = getBoundingClientRect(t, true, e === "fixed"); const o = n.top + t.clientTop; const i = n.left + t.clientLeft; const s = isHTMLElement(t) ? getScale(t) : createCoords(1); const r = t.clientWidth * s.x; const c = t.clientHeight * s.y; const l = i * s.x; const a = o * s.y; return { width: r, height: c, x: l, y: a }; } function getClientRectFromClippingAncestor(t, e, n) { let o; if (e === "viewport") { o = getViewportRect(t, n); } else if (e === "document") { o = getDocumentRect(getDocumentElement(t)); } else if (isElement(e)) { o = getInnerBoundingClientRect(e, n); } else { const n = getVisualOffsets(t); o = { x: e.x - n.x, y: e.y - n.y, width: e.width, height: e.height }; } return rectToClientRect(o); } function hasFixedPositionAncestor(t, e) { const n = getParentNode(t); if (n === e || !isElement(n) || isLastTraversableNode(n)) { return false; } return getComputedStyle$1(n).position === "fixed" || hasFixedPositionAncestor(n, e); } // A "clipping ancestor" is an `overflow` element with the characteristic of // clipping (or hiding) child elements. This returns all clipping ancestors // of the given element up the tree. function getClippingElementAncestors(t, e) { const n = e.get(t); if (n) { return n; } let o = getOverflowAncestors(t, [], false).filter((t => isElement(t) && getNodeName(t) !== "body")); let i = null; const s = getComputedStyle$1(t).position === "fixed"; let r = s ? getParentNode(t) : t; // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block while (isElement(r) && !isLastTraversableNode(r)) { const e = getComputedStyle$1(r); const n = isContainingBlock(r); if (!n && e.position === "fixed") { i = null; } const c = s ? !n && !i : !n && e.position === "static" && !!i && A.has(i.position) || isOverflowElement(r) && !n && hasFixedPositionAncestor(t, r); if (c) { // Drop non-containing blocks. o = o.filter((t => t !== r)); } else { // Record last containing block for next iteration. i = e; } r = getParentNode(r); } e.set(t, o); return o; } // Gets the maximum area that the element is visible in due to any number of // clipping ancestors. function getClippingRect(t) { let {element: e, boundary: i, rootBoundary: s, strategy: r} = t; const c = i === "clippingAncestors" ? isTopLayer(e) ? [] : getClippingElementAncestors(e, this._c) : [].concat(i); const l = [ ...c, s ]; const a = l[0]; const f = l.reduce(((t, i) => { const s = getClientRectFromClippingAncestor(e, i, r); t.top = o(s.top, t.top); t.right = n(s.right, t.right); t.bottom = n(s.bottom, t.bottom); t.left = o(s.left, t.left); return t; }), getClientRectFromClippingAncestor(e, a, r)); return { width: f.right - f.left, height: f.bottom - f.top, x: f.left, y: f.top }; } function getDimensions(t) { const {width: e, height: n} = getCssDimensions(t); return { width: e, height: n }; } function getRectRelativeToOffsetParent(t, e, n) { const o = isHTMLElement(e); const i = getDocumentElement(e); const s = n === "fixed"; const r = getBoundingClientRect(t, true, s, e); let c = { scrollLeft: 0, scrollTop: 0 }; const l = createCoords(0); // If the <body> scrollbar appears on the left (e.g. RTL systems). Use // Firefox with layout.scrollbar.side = 3 in about:config to test this. function setLeftRTLScrollbarOffset() { l.x = getWindowScrollBarX(i); } if (o || !o && !s) { if (getNodeName(e) !== "body" || isOverflowElement(i)) { c = getNodeScroll(e); } if (o) { const t = getBoundingClientRect(e, true, s, e); l.x = t.x + e.clientLeft; l.y = t.y + e.clientTop; } else if (i) { setLeftRTLScrollbarOffset(); } } if (s && !o && i) { setLeftRTLScrollbarOffset(); } const a = i && !o && !s ? getHTMLOffset(i, c) : createCoords(0); const f = r.left + c.scrollLeft - l.x - a.x; const u = r.top + c.scrollTop - l.y - a.y; return { x: f, y: u, width: r.width, height: r.height }; } function isStaticPositioned(t) { return getComputedStyle$1(t).position === "static"; } function getTrueOffsetParent(t, e) { if (!isHTMLElement(t) || getComputedStyle$1(t).position === "fixed") { return null; } if (e) { return e(t); } let n = t.offsetParent; // Firefox returns the <html> element as the offsetParent if it's non-static, // while Chrome and Safari return the <body> element. The <body> element must // be used to perform the correct calculations even if the <html> element is // non-static. if (getDocumentElement(t) === n) { n = n.ownerDocument.body; } return n; } // Gets the closest ancestor positioned element. Handles some edge cases, // such as table ancestors and cross browser bugs. function getOffsetParent(t, e) { const n = getWindow(t); if (isTopLayer(t)) { return n; } if (!isHTMLElement(t)) { let e = getParentNode(t); while (e && !isLastTraversableNode(e)) { if (isElement(e) && !isStaticPositioned(e)) { return e; } e = getParentNode(e); } return n; } let o = getTrueOffsetParent(t, e); while (o && isTableElement(o) && isStaticPositioned(o)) { o = getTrueOffsetParent(o, e); } if (o && isLastTraversableNode(o) && isStaticPositioned(o) && !isContainingBlock(o)) { return n; } return o || getContainingBlock(t) || n; } const getElementRects = async function(t) { const e = this.getOffsetParent || getOffsetParent; const n = this.getDimensions; const o = await n(t.floating); return { reference: getRectRelativeToOffsetParent(t.reference, await e(t.floating), t.strategy), floating: { x: 0, y: 0, width: o.width, height: o.height } }; }; function isRTL(t) { return getComputedStyle$1(t).direction === "rtl"; } const O = { convertOffsetParentRelativeRectToViewportRelativeRect, getDocumentElement, getClippingRect, getOffsetParent, getElementRects, getClientRects, getDimensions, getScale, isElement, isRTL }; function rectsAreEqual(t, e) { return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height; } // https://samthor.au/2021/observing-dom/ function observeMove(t, e) { let i = null; let r; const c = getDocumentElement(t); function cleanup() { var t; clearTimeout(r); (t = i) == null || t.disconnect(); i = null; } function refresh(l, a) { if (l === void 0) { l = false; } if (a === void 0) { a = 1; } cleanup(); const f = t.getBoundingClientRect(); const {left: u, top: d, width: g, height: m} = f; if (!l) { e(); } if (!g || !m) { return; } const p = s(d); const h = s(c.clientWidth - (u + g)); const w = s(c.clientHeight - (d + m)); const y = s(u); const v = -p + "px " + -h + "px " + -w + "px " + -y + "px"; const x = { rootMargin: v, threshold: o(0, n(1, a)) || 1 }; let b = true; function handleObserve(e) { const n = e[0].intersectionRatio; if (n !== a) { if (!b) { return refresh(); } if (!n) { // If the reference is clipped, the ratio is 0. Throttle the refresh // to prevent an infinite loop of updates. r = setTimeout((() => { refresh(false, 1e-7); }), 1e3); } else { refresh(false, n); } } if (n === 1 && !rectsAreEqual(f, t.getBoundingClientRect())) { // It's possible that even though the ratio is reported as 1, the // element is not actually fully within the IntersectionObserver's root // area anymore. This can happen under performance constraints. This may // be a bug in the browser's IntersectionObserver implementation. To // work around this, we compare the element's bounding rect now with // what it was at the time we created the IntersectionObserver. If they // are not equal then the element moved, so we refresh. refresh(); } b = false; } // Older browsers don't support a `document` as the root and will throw an // error. try { i = new IntersectionObserver(handleObserve, { ...x, // Handle <iframe>s root: c.ownerDocument }); } catch (t) { i = new IntersectionObserver(handleObserve, x); } i.observe(t); } refresh(true); return cleanup; } /** * Automatically updates the position of the floating element when necessary. * Should only be called when the floating element is mounted on the DOM or * visible on the screen. * @returns cleanup function that should be invoked when the floating element is * removed from the DOM or hidden from the screen. * @see https://floating-ui.com/docs/autoUpdate */ function autoUpdate(t, e, n, o) { if (o === void 0) { o = {}; } const {ancestorScroll: i = true, ancestorResize: s = true, elementResize: r = typeof ResizeObserver === "function", layoutShift: c = typeof IntersectionObserver === "function", animationFrame: l = false} = o; const a = unwrapElement(t); const f = i || s ? [ ...a ? getOverflowAncestors(a) : [], ...getOverflowAncestors(e) ] : []; f.forEach((t => { i && t.addEventListener("scroll", n, { passive: true }); s && t.addEventListener("resize", n); })); const u = a && c ? observeMove(a, n) : null; let d = -1; let g = null; if (r) { g = new ResizeObserver((t => { let [o] = t; if (o && o.target === a && g) { // Prevent update loops when using the `size` middleware. // https://github.com/floating-ui/floating-ui/issues/1740 g.unobserve(e); cancelAnimationFrame(d); d = requestAnimationFrame((() => { var t; (t = g) == null || t.observe(e); })); } n(); })); if (a && !l) { g.observe(a); } g.observe(e); } let m; let p = l ? getBoundingClientRect(t) : null; if (l) { frameLoop(); } function frameLoop() { const e = getBoundingClientRect(t); if (p && !rectsAreEqual(p, e)) { n(); } p = e; m = requestAnimationFrame(frameLoop); } n(); return () => { var t; f.forEach((t => { i && t.removeEventListener("scroll", n); s && t.removeEventListener("resize", n); })); u == null || u(); (t = g) == null || t.disconnect(); g = null; if (l) { cancelAnimationFrame(m); } }; } /** * Modifies the placement by translating the floating element along the * specified axes. * A number (shorthand for `mainAxis` or distance), or an axes configuration * object may be passed. * @see https://floating-ui.com/docs/offset */ const C = offset$1; /** * Optimizes the visibility of the floating element by shifting it in order to * keep it in view when it will overflow the clipping boundary. * @see https://floating-ui.com/docs/shift */ const E = shift$1; /** * Optimizes the visibility of the floating element by flipping the `placement` * in order to keep it in view when the preferred placement(s) will overflow the * clipping boundary. Alternative to `autoPlacement`. * @see https://floating-ui.com/docs/flip */ const P = flip$1; /** * Provides data to hide the floating element in applicable situations, such as * when it is not in the same clipping context as the reference element. * @see https://floating-ui.com/docs/hide */ const R = hide$1; /** * Provides data to position an inner element of the floating element so that it * appears centered to the reference element. * @see https://floating-ui.com/docs/arrow */ const T = arrow$1; /** * Computes the `x` and `y` coordinates that will place the floating element * next to a given reference element. */ const computePosition = (t, e, n) => { // This caches the expensive `getClippingElementAncestors` function so that // multiple lifecycle resets re-use the same result. It only lives for a // single call. If other functions become expensive, we can add them as well. const o = new Map; const i = { platform: O, ...n }; const s = { ...i.platform, _c: o }; return computePosition$1(t, e, { ...i, platform: s }); }; /** * FloatingUIManager é uma classe utilitária que gerencia o posicionamento de elementos flutuantes * como tooltips ou popovers em relação a um elemento de disparo (trigger). * Ela utiliza a biblioteca Floating UI para calcular posições e lidar com atualizações. */ class L { constructor(t) { var e; this.triggerElement = t.triggerElement; this.contentElement = t.contentElement; this.arrowElement = t.arrowElement; this.placement = (e = t.placement) !== null && e !== void 0 ? e : "top"; this.onUpdate = t.onUpdate; } /** * Inicia o gerenciador Floating UI configurando a atualização automática da posição. */ start() { this.cleanupAutoUpdate = autoUpdate(this.triggerElement, this.contentElement, (() => this.updatePosition())); } /** * Para o gerenciador Floating UI e limpa os recursos utilizados. */ stop() { var t; (t = this.cleanupAutoUpdate) === null || t === void 0 ? void 0 : t.call(this); } /** * Atualiza a posição do elemento flutuante com base no elemento disparador e no elemento de conteúdo. * Esta função é chamada automaticamente quando o gerenciador está ativo. * Ela calcula a nova posição usando a biblioteca Floating UI e aplica as transformações necessárias. * Também atualiza a posição da seta, se fornecida. * Além disso, define o atributo de dados `data-placement` no elemento de conteúdo para refletir a posição atual. * @returns {Promise<void>} Uma promessa que resolve quando a posição é atualizada. */ updatePosition() { return t(this, void 0, void 0, (function*() { var t; const e = yield computePosition(this.triggerElement, this.contentElement, { placement: this.placement, middleware: this.buildMiddleware() }); this.updateTooltipPosition(e); this.updateArrowPosition(e); this.setPlacementDataAttribute(e); (t = this.onUpdate) === null || t === void 0 ? void 0 : t.call(this, e); })); } /** * Constrói os middlewares necessários para o Floating UI. * Esses middlewares são usados para ajustar o posicionamento do elemento flutuante, * incluindo offset, flip, shift e hide. Se uma seta for fornecida, o middleware de seta também é adicionado. * @returns {Middleware[]} Retorna um array de middlewares configurados para o Floating UI. */ buildMiddleware() { const t = [ C(8), P(), E({ padding: 5 }), R() ]; if (this.arrowElement != null) { t.push(T({ element: this.arrowElement })); } return t; } /** * Adiciona o estilo necessário para posicionar o tooltip com base nas coordenadas fornecidas. * Esta função é chamada após o cálculo da posição do tooltip. * Ela aplica as propriedades CSS `left` e `top` ao elemento de conteúdo do tooltip. * @param data Contém as coordenadas x e y para posicionar o tooltip. */ updateTooltipPosition(t) { const {x: e, y: n} = t; Object.assign(this.contentElement.style, { left: `${e}px`, top: `${n}px` }); } /** * Adiciona o estilo necessário para posicionar a seta do tooltip com base nos dados de middleware. * Esta função é chamada após o cálculo da posição do tooltip. * Ela aplica as propriedades CSS `left`, `top`, `right`, `bottom` e a posição estática da seta. * A posição estática é determinada com base na colocação do tooltip (top, right, bottom, left). * Se a seta não estiver presente ou os dados de middleware não contiverem informações sobre a seta, nada será feito. * @param data Contém a posição da seta e os dados de middleware. */ updateArrowPosition(t) { if (this.arrowElement == null || t.middlewareData.arrow == null) return; const {x: e, y: n} = t.middlewareData.arrow; const o = t.placement.split("-")[0]; const i = { top: "bottom", right: "left", bottom: "top", left: "right" }[o]; Object.assign(this.arrowElement.style, { left: e != null ? `${e}px` : "", top: n != null ? `${n}px` : "", right: "", bottom: "", [i]: "-4px" }); } /** * Define o atributo de dados `data-placement` no elemento de conteúdo. * Este atributo é usado para indicar a posição atual do tooltip ou popover. * Ele é útil para fins de acessibilidade e para permitir que estilos CSS sejam aplicados com base na posição. * @param data Objeto contendo a propriedade `placement` que define a posição do tooltip ou popover. * A propriedade `placement` deve ser uma string representando a posição, como 'top', 'bottom', 'left', 'right', etc. */ setPlacementDataAttribute(t) { this.contentElement.setAttribute("data-placement", t.placement); } } export { L as F }; //# sourceMappingURL=p-CNNuop_Z.js.map //# sourceMappingURL=p-CNNuop_Z.js.map