@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
178 lines (177 loc) • 5.87 kB
JavaScript
"use client";
import { jsx as k } from "react/jsx-runtime";
import { d as S } from "./chunks/index.D-sRdssb.js";
import { isValidElement as V, useState as G, createContext as J, forwardRef as U, cloneElement as K, useContext as L } from "react";
import { j as Q, o as W, s as X, a as Y, u as Z, m as tt, n as et, c as ot, d as st, e as nt, f as H, g as lt, i as it } from "./chunks/floating-ui.react.COTL3jH5.js";
import { c as ct } from "./chunks/index.DL9mof6u.js";
import { g as y, c as I } from "./chunks/helpers.CexwVao7.js";
import './assets/tooltip.Co1gWF_0.css';const rt = "ds-tooltip_tooltip_503ch_5", at = {
tooltip: rt
};
function pt(s) {
const t = S.c(24), {
initialOpen: e,
placement: o,
isOpen: r,
tooltipOffset: n,
onOpenChange: u
} = s === void 0 ? {} : s, a = e === void 0 ? !1 : e, l = o === void 0 ? "top" : o, i = n === void 0 ? 6 : n, [x, T] = G(a), p = r ?? x, d = u ?? T, O = "fixed", w = Y, v = W(i), C = Q({
crossAxis: l.includes("-"),
fallbackAxisSideDirection: "start",
padding: i
}), m = X({
padding: i
});
let c;
t[0] !== v || t[1] !== C || t[2] !== m ? (c = [v, C, m], t[0] = v, t[1] = C, t[2] = m, t[3] = c) : c = t[3];
let g;
t[4] !== p || t[5] !== l || t[6] !== d || t[7] !== w || t[8] !== c ? (g = {
placement: l,
open: p,
strategy: O,
onOpenChange: d,
whileElementsMounted: w,
middleware: c
}, t[4] = p, t[5] = l, t[6] = d, t[7] = w, t[8] = c, t[9] = g) : g = t[9];
const f = Z(g), h = f.context;
let E;
t[10] === Symbol.for("react.memo_cache_sentinel") ? (E = {
move: !1,
enabled: !0,
mouseOnly: !0,
delay: {
open: 400,
close: 0
}
}, t[10] = E) : E = t[10];
const P = tt(h, E);
let A;
t[11] === Symbol.for("react.memo_cache_sentinel") ? (A = {
enabled: !0
}, t[11] = A) : A = t[11];
const D = et(h, A), R = ot(h);
let _;
t[12] === Symbol.for("react.memo_cache_sentinel") ? (_ = {
role: "tooltip"
}, t[12] = _) : _ = t[12];
const M = st(h, _);
let N;
t[13] !== R || t[14] !== D || t[15] !== P || t[16] !== M ? (N = [P, D, R, M], t[13] = R, t[14] = D, t[15] = P, t[16] = M, t[17] = N) : N = t[17];
const $ = nt(N);
let b;
return t[18] !== f || t[19] !== $ || t[20] !== p || t[21] !== d || t[22] !== i ? (b = {
open: p,
tooltipOffset: i,
setOpen: d,
...$,
...f
}, t[18] = f, t[19] = $, t[20] = p, t[21] = d, t[22] = i, t[23] = b) : b = t[23], b;
}
const ft = (s) => {
if (!V(s))
throw new Error(y("Tooltip", "Tooltip.Anchor child must be a valid React element."));
}, dt = ({
children: s,
hasContent: t,
hasAnchor: e
}) => {
if (!s)
throw new Error(y("Tooltip", "A Tooltip must have children."));
if (!t)
throw new Error(y("Tooltip", "A Tooltip must have a <Tooltip.Content> component as a child. Please add it to the children of Tooltip."));
if (!e)
throw new Error(y("Tooltip", "A Tooltip must have a <Tooltip.Anchor> component as a child. Please add it to the children of Tooltip."));
}, q = J(null), z = () => {
const s = L(q);
if (s == null)
throw new Error(y("Tooltip", "Components like Tooltip.Anchor or Tooltip.Content must be wrapped in <Tooltip />."));
return s;
}, F = (s) => {
const t = S.c(9);
let e, o;
t[0] !== s ? ({
children: e,
...o
} = s, t[0] = s, t[1] = e, t[2] = o) : (e = t[1], o = t[2]);
let r;
t[3] !== o ? (r = {
...o
}, t[3] = o, t[4] = r) : r = t[4];
const n = pt(r), u = I(e, F.Content), a = I(e, j);
process.env.NODE_ENV !== "production" && dt({
children: e,
hasContent: u,
hasAnchor: a
});
let l;
return t[5] !== e || t[6] !== o || t[7] !== n ? (l = /* @__PURE__ */ k(q.Provider, { value: n, ...o, children: e }), t[5] = e, t[6] = o, t[7] = n, t[8] = l) : l = t[8], l;
}, j = U((s, t) => {
const e = S.c(4), {
children: o,
...r
} = s;
process.env.NODE_ENV !== "production" && ft(o);
const n = z(), u = V(o) ? o.ref : null;
let a;
e[0] !== u || e[1] !== n.refs.setReference || e[2] !== t ? (a = [n.refs.setReference, t, u], e[0] = u, e[1] = n.refs.setReference, e[2] = t, e[3] = a) : a = e[3];
const l = H(a);
if (V(o))
return K(o, n.getReferenceProps({
...o.props,
...r,
ref: l,
"data-state": n.open ? "open" : "closed"
}));
});
j.displayName = "Tooltip.Anchor";
const B = U((s, t) => {
const e = S.c(24), {
style: o,
className: r,
children: n,
...u
} = s, a = z();
let l, i, x, T;
e[0] !== a ? ({
context: l,
floatingStyles: i,
getFloatingProps: x,
...T
} = a, e[0] = a, e[1] = l, e[2] = i, e[3] = x, e[4] = T) : (l = e[1], i = e[2], x = e[3], T = e[4]);
let p;
e[5] !== t || e[6] !== T.refs.setFloating ? (p = [T.refs.setFloating, t], e[5] = t, e[6] = T.refs.setFloating, e[7] = p) : p = e[7];
const d = H(p);
let O;
e[8] === Symbol.for("react.memo_cache_sentinel") ? (O = {
duration: {
open: 400,
close: 100
}
}, e[8] = O) : O = e[8];
const {
isMounted: w,
status: v
} = lt(l, O);
if (!w)
return null;
const C = it;
let m;
e[9] !== i || e[10] !== o ? (m = {
...i,
...o
}, e[9] = i, e[10] = o, e[11] = m) : m = e[11];
let c;
e[12] !== r ? (c = ct(at.tooltip, r), e[12] = r, e[13] = c) : c = e[13];
const g = x(u);
let f;
e[14] !== n || e[15] !== d || e[16] !== v || e[17] !== m || e[18] !== c || e[19] !== g ? (f = /* @__PURE__ */ k("div", { ref: d, style: m, className: c, ...g, "data-status": v, children: n }), e[14] = n, e[15] = d, e[16] = v, e[17] = m, e[18] = c, e[19] = g, e[20] = f) : f = e[20];
let h;
return e[21] !== C || e[22] !== f ? (h = /* @__PURE__ */ k(C, { children: f }), e[21] = C, e[22] = f, e[23] = h) : h = e[23], h;
});
B.displayName = "Tooltip.Content";
F.Anchor = j;
F.Content = B;
F.displayName = "Tooltip";
export {
F as Tooltip
};