UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

192 lines (191 loc) 6.53 kB
"use client"; import { jsx as $ } from "react/jsx-runtime"; import { d as N } from "./chunks/index.CgTHIF3K.js"; import { isValidElement as k, useState as G, createContext as J, forwardRef as j, cloneElement as K, useContext as L } from "react"; import { i as Q, u as W, l as X, m as Y, b as Z, c as ee, d as te, o as oe, s as se, e as H, f as le, g as ne } from "./chunks/floating-ui.react.DCyAzlZ4.js"; import { c as ie } from "./chunks/index.CEyLAtio.js"; import { g as O, c as U } from "./chunks/helpers.BbWkXTr3.js"; import { a as re } from "./chunks/floating-ui.dom.VgHc0h4l.js"; import './assets/tooltip.Co1gWF_0.css';const ce = "ds-tooltip_tooltip_503ch_5", ae = { tooltip: ce }; function fe(s) { const t = N.c(32); let e; t[0] !== s ? (e = s === void 0 ? {} : s, t[0] = s, t[1] = e) : e = t[1]; const { initialOpen: o, placement: l, isOpen: n, tooltipOffset: c, onOpenChange: d } = e, a = o === void 0 ? !1 : o, r = l === void 0 ? "top" : l, i = c === void 0 ? 6 : c, [v, x] = G(a), h = n ?? v, m = d ?? x; let C; t[2] !== i ? (C = oe(i), t[2] = i, t[3] = C) : C = t[3]; let T; t[4] !== r || t[5] !== i ? (T = Q({ crossAxis: r.includes("-"), fallbackAxisSideDirection: "start", padding: i }), t[4] = r, t[5] = i, t[6] = T) : T = t[6]; let f; t[7] !== i ? (f = se({ padding: i }), t[7] = i, t[8] = f) : f = t[8]; let p; t[9] !== C || t[10] !== T || t[11] !== f ? (p = [C, T, f], t[9] = C, t[10] = T, t[11] = f, t[12] = p) : p = t[12]; let u; t[13] !== h || t[14] !== r || t[15] !== m || t[16] !== p ? (u = { placement: r, open: h, strategy: "fixed", onOpenChange: m, whileElementsMounted: re, middleware: p }, t[13] = h, t[14] = r, t[15] = m, t[16] = p, t[17] = u) : u = t[17]; const g = W(u), w = g.context; let y; t[18] === Symbol.for("react.memo_cache_sentinel") ? (y = { move: !1, enabled: !0, mouseOnly: !0, delay: { open: 400, close: 0 } }, t[18] = y) : y = t[18]; const F = X(w, y); let E; t[19] === Symbol.for("react.memo_cache_sentinel") ? (E = { enabled: !0 }, t[19] = E) : E = t[19]; const P = Y(w, E), D = Z(w); let A; t[20] === Symbol.for("react.memo_cache_sentinel") ? (A = { role: "tooltip" }, t[20] = A) : A = t[20]; const R = ee(w, A); let _; t[21] !== D || t[22] !== P || t[23] !== F || t[24] !== R ? (_ = [F, P, D, R], t[21] = D, t[22] = P, t[23] = F, t[24] = R, t[25] = _) : _ = t[25]; const M = te(_); let I, b; return t[26] !== g || t[27] !== M || t[28] !== h || t[29] !== m || t[30] !== i ? (b = { open: h, tooltipOffset: i, setOpen: m, ...M, ...g }, t[26] = g, t[27] = M, t[28] = h, t[29] = m, t[30] = i, t[31] = b) : b = t[31], I = b, I; } const pe = (s) => { if (!k(s)) throw new Error(O("Tooltip", "Tooltip.Anchor child must be a valid React element.")); }, de = ({ children: s, hasContent: t, hasAnchor: e }) => { if (!s) throw new Error(O("Tooltip", "A Tooltip must have children.")); if (!t) throw new Error(O("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(O("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(O("Tooltip", "Components like Tooltip.Anchor or Tooltip.Content must be wrapped in <Tooltip />.")); return s; }, S = (s) => { const t = N.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 l; t[3] !== o ? (l = { ...o }, t[3] = o, t[4] = l) : l = t[4]; const n = fe(l), c = U(e, S.Content), d = U(e, V); process.env.NODE_ENV !== "production" && de({ children: e, hasContent: c, hasAnchor: d }); let a; return t[5] !== e || t[6] !== o || t[7] !== n ? (a = /* @__PURE__ */ $(q.Provider, { value: n, ...o, children: e }), t[5] = e, t[6] = o, t[7] = n, t[8] = a) : a = t[8], a; }, V = j((s, t) => { const e = N.c(12); let o, l; e[0] !== s ? ({ children: o, ...l } = s, e[0] = s, e[1] = o, e[2] = l) : (o = e[1], l = e[2]), process.env.NODE_ENV !== "production" && pe(o); const n = z(), c = k(o) ? o.ref : null; let d; e[3] !== c || e[4] !== n.refs.setReference || e[5] !== t ? (d = [n.refs.setReference, t, c], e[3] = c, e[4] = n.refs.setReference, e[5] = t, e[6] = d) : d = e[6]; const a = H(d); if (k(o)) { let r; return e[7] !== o || e[8] !== n || e[9] !== l || e[10] !== a ? (r = K(o, n.getReferenceProps({ ...o.props, ...l, ref: a, "data-state": n.open ? "open" : "closed" })), e[7] = o, e[8] = n, e[9] = l, e[10] = a, e[11] = r) : r = e[11], r; } }); V.displayName = "Tooltip.Anchor"; const B = j((s, t) => { const e = N.c(29); let o, l, n, c; e[0] !== s ? ({ style: c, className: l, children: o, ...n } = s, e[0] = s, e[1] = o, e[2] = l, e[3] = n, e[4] = c) : (o = e[1], l = e[2], n = e[3], c = e[4]); const d = z(); let a, r, i, v; e[5] !== d ? ({ context: a, floatingStyles: r, getFloatingProps: i, ...v } = d, e[5] = d, e[6] = a, e[7] = r, e[8] = i, e[9] = v) : (a = e[6], r = e[7], i = e[8], v = e[9]); let x; e[10] !== t || e[11] !== v.refs.setFloating ? (x = [v.refs.setFloating, t], e[10] = t, e[11] = v.refs.setFloating, e[12] = x) : x = e[12]; const h = H(x); let m; e[13] === Symbol.for("react.memo_cache_sentinel") ? (m = { duration: { open: 400, close: 100 } }, e[13] = m) : m = e[13]; const { isMounted: C, status: T } = le(a, m); if (!C) return null; let f; e[14] !== r || e[15] !== c ? (f = { ...r, ...c }, e[14] = r, e[15] = c, e[16] = f) : f = e[16]; let p; e[17] !== l ? (p = ie(ae.tooltip, l), e[17] = l, e[18] = p) : p = e[18]; let u; e[19] !== i || e[20] !== n ? (u = i(n), e[19] = i, e[20] = n, e[21] = u) : u = e[21]; let g; return e[22] !== o || e[23] !== h || e[24] !== T || e[25] !== f || e[26] !== p || e[27] !== u ? (g = /* @__PURE__ */ $(ne, { children: /* @__PURE__ */ $("div", { ref: h, style: f, className: p, ...u, "data-status": T, children: o }) }), e[22] = o, e[23] = h, e[24] = T, e[25] = f, e[26] = p, e[27] = u, e[28] = g) : g = e[28], g; }); B.displayName = "Tooltip.Content"; S.Anchor = V; S.Content = B; S.displayName = "Tooltip"; export { S as Tooltip };