@gnome-ui/react 1.38.1 → 1.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +8 -6
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.module.css.cjs +1 -1
- package/dist/components/Button/Button.module.css.cjs.map +1 -1
- package/dist/components/Button/Button.module.css.js +11 -11
- package/dist/components/Button/Button.module.css.js.map +1 -1
- package/dist/components/IconButton/IconButton.cjs +2 -0
- package/dist/components/IconButton/IconButton.cjs.map +1 -0
- package/dist/components/IconButton/IconButton.d.ts +30 -0
- package/dist/components/IconButton/IconButton.js +35 -0
- package/dist/components/IconButton/IconButton.js.map +1 -0
- package/dist/components/IconButton/index.d.ts +2 -0
- package/dist/components/IconButton.cjs +1 -0
- package/dist/components/IconButton.d.ts +2 -0
- package/dist/components/IconButton.js +2 -0
- package/dist/components/Sidebar/SidebarItem.cjs +1 -1
- package/dist/components/Sidebar/SidebarItem.js +15 -15
- package/dist/components/Skeleton/Skeleton.cjs +2 -0
- package/dist/components/Skeleton/Skeleton.cjs.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +26 -0
- package/dist/components/Skeleton/Skeleton.js +47 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.module.css.cjs +2 -0
- package/dist/components/Skeleton/Skeleton.module.css.cjs.map +1 -0
- package/dist/components/Skeleton/Skeleton.module.css.js +13 -0
- package/dist/components/Skeleton/Skeleton.module.css.js.map +1 -0
- package/dist/components/Skeleton/index.d.ts +2 -0
- package/dist/components/Skeleton.cjs +1 -0
- package/dist/components/Skeleton.d.ts +2 -0
- package/dist/components/Skeleton.js +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +48 -37
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +56 -54
- package/dist/style.css +1 -1
- package/package.json +11 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.cjs","names":[],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\n useState,\n useRef,\n useId,\n useCallback,\n useEffect,\n cloneElement,\n type ReactElement,\n type HTMLAttributes,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport styles from \"./Tooltip.module.css\";\n\nexport type TooltipPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport interface TooltipProps {\n /**\n * The tooltip label. Keep it short — a noun phrase or brief description.\n * Do not duplicate information already visible on screen.\n */\n label: string;\n /**\n * Preferred placement relative to the trigger.\n * The tooltip flips automatically if there is not enough space.\n * Defaults to `\"top\"`.\n */\n placement?: TooltipPlacement;\n /**\n * Delay in milliseconds before the tooltip appears on hover.\n * Defaults to `500`. Set to `0` for instant.\n */\n delay?: number;\n /**\n * The element that triggers the tooltip.\n * Must be a single React element that can receive `ref` and event props.\n */\n children: ReactElement<HTMLAttributes<HTMLElement>>;\n}\n\ninterface Position {\n top: number;\n left: number;\n placement: TooltipPlacement;\n}\n\nconst GAP = 6; // px between trigger and tooltip\n\nfunction computePosition(\n trigger: DOMRect,\n tooltip: DOMRect,\n preferred: TooltipPlacement\n): Position {\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n\n const placements: TooltipPlacement[] = [\n preferred,\n preferred === \"top\" || preferred === \"bottom\"\n ? preferred === \"top\" ? \"bottom\" : \"top\"\n : preferred === \"left\" ? \"right\" : \"left\",\n \"top\",\n \"bottom\",\n \"left\",\n \"right\",\n ];\n\n for (const p of placements) {\n let top = 0;\n let left = 0;\n\n if (p === \"top\") {\n top = trigger.top - tooltip.height - GAP;\n left = trigger.left + trigger.width / 2 - tooltip.width / 2;\n } else if (p === \"bottom\") {\n top = trigger.bottom + GAP;\n left = trigger.left + trigger.width / 2 - tooltip.width / 2;\n } else if (p === \"left\") {\n top = trigger.top + trigger.height / 2 - tooltip.height / 2;\n left = trigger.left - tooltip.width - GAP;\n } else {\n top = trigger.top + trigger.height / 2 - tooltip.height / 2;\n left = trigger.right + GAP;\n }\n\n // Clamp to viewport with 8 px margin\n const margin = 8;\n const fitsH = left >= margin && left + tooltip.width <= vw - margin;\n const fitsV = top >= margin && top + tooltip.height <= vh - margin;\n\n if (fitsH && fitsV) {\n return {\n top: Math.max(margin, Math.min(top, vh - tooltip.height - margin)),\n left: Math.max(margin, Math.min(left, vw - tooltip.width - margin)),\n placement: p,\n };\n }\n }\n\n // Fallback: clamp preferred\n let top = 0, left = 0;\n if (preferred === \"top\") { top = trigger.top - tooltip.height - GAP; left = trigger.left + trigger.width / 2 - tooltip.width / 2; }\n if (preferred === \"bottom\") { top = trigger.bottom + GAP; left = trigger.left + trigger.width / 2 - tooltip.width / 2; }\n if (preferred === \"left\") { top = trigger.top + trigger.height / 2 - tooltip.height / 2; left = trigger.left - tooltip.width - GAP; }\n if (preferred === \"right\") { top = trigger.top + trigger.height / 2 - tooltip.height / 2; left = trigger.right + GAP; }\n\n const margin = 8;\n return {\n top: Math.max(margin, Math.min(top, vh - tooltip.height - margin)),\n left: Math.max(margin, Math.min(left, window.innerWidth - tooltip.width - margin)),\n placement: preferred,\n };\n}\n\n/**\n * Informational tooltip following the Adwaita / GNOME HIG pattern.\n *\n * Wraps a single trigger element and shows a floating label on hover or\n * keyboard focus. The tooltip is positioned automatically and flips if\n * there is not enough space.\n *\n * - `aria-describedby` is wired to the trigger automatically.\n * - The tooltip itself is `role=\"tooltip\"` and rendered in a portal.\n * - Does not show on touch — touch devices have no hover state.\n *\n * @example\n * <Tooltip label=\"Save file (Ctrl+S)\">\n * <Button aria-label=\"Save\"><Icon icon={Save} /></Button>\n * </Tooltip>\n *\n * @see https://developer.gnome.org/hig/patterns/feedback/tooltips.html\n */\nexport function Tooltip({\n label,\n placement: preferredPlacement = \"top\",\n delay = 500,\n children,\n}: TooltipProps) {\n const id = useId();\n const [visible, setVisible] = useState(false);\n const [pos, setPos] = useState<Position | null>(null);\n\n const triggerRef = useRef<HTMLElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const clearTimer = () => {\n if (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; }\n };\n\n const place = useCallback(() => {\n if (!triggerRef.current || !tooltipRef.current) return;\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const tooltipRect = tooltipRef.current.getBoundingClientRect();\n setPos(computePosition(triggerRect, tooltipRect, preferredPlacement));\n }, [preferredPlacement]);\n\n // Reposition on scroll/resize while visible\n useEffect(() => {\n if (!visible) return;\n place();\n window.addEventListener(\"scroll\", place, { passive: true, capture: true });\n window.addEventListener(\"resize\", place, { passive: true });\n return () => {\n window.removeEventListener(\"scroll\", place, { capture: true });\n window.removeEventListener(\"resize\", place);\n };\n }, [visible, place]);\n\n const show = useCallback(() => {\n clearTimer();\n timerRef.current = setTimeout(() => setVisible(true), delay);\n }, [delay]);\n\n const hide = useCallback(() => {\n clearTimer();\n setVisible(false);\n setPos(null);\n }, []);\n\n // Position as soon as the tooltip mounts\n useEffect(() => {\n if (visible) place();\n }, [visible, place]);\n\n // Dismiss on Escape\n useEffect(() => {\n if (!visible) return;\n const handler = (e: KeyboardEvent) => { if (e.key === \"Escape\") hide(); };\n document.addEventListener(\"keydown\", handler);\n return () => document.removeEventListener(\"keydown\", handler);\n }, [visible, hide]);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const child = cloneElement(children as any, {\n ref: triggerRef,\n \"aria-describedby\": id,\n onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n show();\n children.props.onMouseEnter?.(e);\n },\n onMouseLeave: (e: React.MouseEvent<HTMLElement>) => {\n hide();\n children.props.onMouseLeave?.(e);\n },\n onFocus: (e: React.FocusEvent<HTMLElement>) => {\n show();\n children.props.onFocus?.(e);\n },\n onBlur: (e: React.FocusEvent<HTMLElement>) => {\n hide();\n children.props.onBlur?.(e);\n },\n });\n\n const tooltip = (\n <div\n ref={tooltipRef}\n id={id}\n role=\"tooltip\"\n className={[\n styles.tooltip,\n pos ? styles[pos.placement] : null,\n visible && pos ? styles.visible : null,\n ]\n .filter(Boolean)\n .join(\" \")}\n style={\n pos\n ? { top: pos.top, left: pos.left }\n : { visibility: \"hidden\", top: -9999, left: -9999 }\n }\n >\n {label}\n </div>\n );\n\n return (\n <>\n {child}\n {typeof document !== \"undefined\"\n ? createPortal(tooltip, document.body)\n : tooltip}\n </>\n );\n}\n"],"mappings":"yHA6CA,IAAM,EAAM,EAEZ,SAAS,EACP,EACA,EACA,EACU,CACV,IAAM,EAAK,OAAO,WACZ,EAAK,OAAO,YAEZ,EAAiC,CACrC,EACA,IAAc,OAAS,IAAc,SACjC,IAAc,MAAQ,SAAW,MACjC,IAAc,OAAS,QAAU,OACrC,MACA,SACA,OACA,QACD,CAED,IAAK,IAAM,KAAK,EAAY,CAC1B,IAAI,EAAM,EACN,EAAO,EAEP,IAAM,OACR,EAAO,EAAQ,IAAO,EAAQ,OAAS,EACvC,EAAO,EAAQ,KAAO,EAAQ,MAAQ,EAAI,EAAQ,MAAQ,GACjD,IAAM,UACf,EAAO,EAAQ,OAAS,EACxB,EAAO,EAAQ,KAAS,EAAQ,MAAQ,EAAI,EAAQ,MAAQ,GACnD,IAAM,QACf,EAAO,EAAQ,IAAO,EAAQ,OAAS,EAAI,EAAQ,OAAS,EAC5D,EAAO,EAAQ,KAAO,EAAQ,MAAQ,IAEtC,EAAO,EAAQ,IAAS,EAAQ,OAAS,EAAI,EAAQ,OAAS,EAC9D,EAAO,EAAQ,MAAS,GAI1B,IACM,EAAQ,GAAQ,GAAU,EAAO,EAAQ,OAAU,EAAK,EACxD,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AAE,EAElC,QAAU,GAAqC,CAC7C,GAAM,CACN,EAAS,MAAM,UAAU,EAAE,EAE7B,OAAS,GAAqC,CAC5C,GAAM,CACN,EAAS,MAAM,SAAS,EAAE,EAE7B,CAAC,CAEI,GACJ,EAAA,EAAA,KAAC,MAAD,CACE,IAAK,EACD,KACJ,KAAK,UACL,UAAW,CACT,EAAA,QAAO,QACP,EAAM,EAAA,QAAO,EAAI,WAAa,KAC9B,GAAW,EAAM,EAAA,QAAO,QAAU,KACnC,CACE,OAAO,QAAQ,CACf,KAAK,IAAI,CACZ,MACE,EACI,CAAE,IAAK,EAAI,IAAK,KAAM,EAAI,KAAM,CAChC,CAAE,WAAY,SAAU,IAAK,MAAO,KAAM,MAAO,UAGtD,EACG,CAAA,CAGR,OACE,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,CACG,EACA,OAAO,SAAa,KAAA,EAAA,EAAA,cACJ,EAAS,SAAS,KAAK,CACpC,EACH,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"Tooltip.cjs","names":[],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\n useState,\n useRef,\n useId,\n useCallback,\n useEffect,\n cloneElement,\n type ReactElement,\n type HTMLAttributes,\n type Ref,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport styles from \"./Tooltip.module.css\";\n\nexport type TooltipPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport interface TooltipProps {\n /**\n * The tooltip label. Keep it short — a noun phrase or brief description.\n * Do not duplicate information already visible on screen.\n */\n label: string;\n /**\n * Preferred placement relative to the trigger.\n * The tooltip flips automatically if there is not enough space.\n * Defaults to `\"top\"`.\n */\n placement?: TooltipPlacement;\n /**\n * Delay in milliseconds before the tooltip appears on hover.\n * Defaults to `500`. Set to `0` for instant.\n */\n delay?: number;\n /**\n * The element that triggers the tooltip.\n * Must be a single React element that can receive `ref` and event props.\n */\n children: ReactElement<HTMLAttributes<HTMLElement>>;\n}\n\ninterface Position {\n top: number;\n left: number;\n placement: TooltipPlacement;\n}\n\nconst GAP = 6; // px between trigger and tooltip\n\nfunction assignRef<T>(ref: Ref<T> | undefined, value: T | null) {\n if (!ref) return;\n if (typeof ref === \"function\") {\n ref(value);\n return;\n }\n ref.current = value;\n}\n\nfunction computePosition(\n trigger: DOMRect,\n tooltip: DOMRect,\n preferred: TooltipPlacement\n): Position {\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n\n const placements: TooltipPlacement[] = [\n preferred,\n preferred === \"top\" || preferred === \"bottom\"\n ? preferred === \"top\" ? \"bottom\" : \"top\"\n : preferred === \"left\" ? \"right\" : \"left\",\n \"top\",\n \"bottom\",\n \"left\",\n \"right\",\n ];\n\n for (const p of placements) {\n let top = 0;\n let left = 0;\n\n if (p === \"top\") {\n top = trigger.top - tooltip.height - GAP;\n left = trigger.left + trigger.width / 2 - tooltip.width / 2;\n } else if (p === \"bottom\") {\n top = trigger.bottom + GAP;\n left = trigger.left + trigger.width / 2 - tooltip.width / 2;\n } else if (p === \"left\") {\n top = trigger.top + trigger.height / 2 - tooltip.height / 2;\n left = trigger.left - tooltip.width - GAP;\n } else {\n top = trigger.top + trigger.height / 2 - tooltip.height / 2;\n left = trigger.right + GAP;\n }\n\n // Clamp to viewport with 8 px margin\n const margin = 8;\n const fitsH = left >= margin && left + tooltip.width <= vw - margin;\n const fitsV = top >= margin && top + tooltip.height <= vh - margin;\n\n if (fitsH && fitsV) {\n return {\n top: Math.max(margin, Math.min(top, vh - tooltip.height - margin)),\n left: Math.max(margin, Math.min(left, vw - tooltip.width - margin)),\n placement: p,\n };\n }\n }\n\n // Fallback: clamp preferred\n let top = 0, left = 0;\n if (preferred === \"top\") { top = trigger.top - tooltip.height - GAP; left = trigger.left + trigger.width / 2 - tooltip.width / 2; }\n if (preferred === \"bottom\") { top = trigger.bottom + GAP; left = trigger.left + trigger.width / 2 - tooltip.width / 2; }\n if (preferred === \"left\") { top = trigger.top + trigger.height / 2 - tooltip.height / 2; left = trigger.left - tooltip.width - GAP; }\n if (preferred === \"right\") { top = trigger.top + trigger.height / 2 - tooltip.height / 2; left = trigger.right + GAP; }\n\n const margin = 8;\n return {\n top: Math.max(margin, Math.min(top, vh - tooltip.height - margin)),\n left: Math.max(margin, Math.min(left, window.innerWidth - tooltip.width - margin)),\n placement: preferred,\n };\n}\n\n/**\n * Informational tooltip following the Adwaita / GNOME HIG pattern.\n *\n * Wraps a single trigger element and shows a floating label on hover or\n * keyboard focus. The tooltip is positioned automatically and flips if\n * there is not enough space.\n *\n * - `aria-describedby` is wired to the trigger automatically.\n * - The tooltip itself is `role=\"tooltip\"` and rendered in a portal.\n * - Does not show on touch — touch devices have no hover state.\n *\n * @example\n * <Tooltip label=\"Save file (Ctrl+S)\">\n * <Button aria-label=\"Save\"><Icon icon={Save} /></Button>\n * </Tooltip>\n *\n * @see https://developer.gnome.org/hig/patterns/feedback/tooltips.html\n */\nexport function Tooltip({\n label,\n placement: preferredPlacement = \"top\",\n delay = 500,\n children,\n}: TooltipProps) {\n const id = useId();\n const [visible, setVisible] = useState(false);\n const [pos, setPos] = useState<Position | null>(null);\n\n const triggerRef = useRef<HTMLElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const clearTimer = () => {\n if (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; }\n };\n\n const place = useCallback(() => {\n if (!triggerRef.current || !tooltipRef.current) return;\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const tooltipRect = tooltipRef.current.getBoundingClientRect();\n setPos(computePosition(triggerRect, tooltipRect, preferredPlacement));\n }, [preferredPlacement]);\n\n // Reposition on scroll/resize while visible\n useEffect(() => {\n if (!visible) return;\n place();\n window.addEventListener(\"scroll\", place, { passive: true, capture: true });\n window.addEventListener(\"resize\", place, { passive: true });\n return () => {\n window.removeEventListener(\"scroll\", place, { capture: true });\n window.removeEventListener(\"resize\", place);\n };\n }, [visible, place]);\n\n const show = useCallback(() => {\n clearTimer();\n timerRef.current = setTimeout(() => setVisible(true), delay);\n }, [delay]);\n\n const hide = useCallback(() => {\n clearTimer();\n setVisible(false);\n setPos(null);\n }, []);\n\n // Position as soon as the tooltip mounts\n useEffect(() => {\n if (visible) place();\n }, [visible, place]);\n\n // Dismiss on Escape\n useEffect(() => {\n if (!visible) return;\n const handler = (e: KeyboardEvent) => { if (e.key === \"Escape\") hide(); };\n document.addEventListener(\"keydown\", handler);\n return () => document.removeEventListener(\"keydown\", handler);\n }, [visible, hide]);\n\n const childRef = (children.props as HTMLAttributes<HTMLElement> & {\n ref?: Ref<HTMLElement>;\n }).ref;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const child = cloneElement(children as any, {\n ref: (node: HTMLElement | null) => {\n triggerRef.current = node;\n assignRef(childRef, node);\n },\n \"aria-describedby\": id,\n onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n show();\n children.props.onMouseEnter?.(e);\n },\n onMouseLeave: (e: React.MouseEvent<HTMLElement>) => {\n hide();\n children.props.onMouseLeave?.(e);\n },\n onFocus: (e: React.FocusEvent<HTMLElement>) => {\n show();\n children.props.onFocus?.(e);\n },\n onBlur: (e: React.FocusEvent<HTMLElement>) => {\n hide();\n children.props.onBlur?.(e);\n },\n });\n\n const tooltip = (\n <div\n ref={tooltipRef}\n id={id}\n role=\"tooltip\"\n className={[\n styles.tooltip,\n pos ? styles[pos.placement] : null,\n visible && pos ? styles.visible : null,\n ]\n .filter(Boolean)\n .join(\" \")}\n style={\n pos\n ? { top: pos.top, left: pos.left }\n : { visibility: \"hidden\", top: -9999, left: -9999 }\n }\n >\n {label}\n </div>\n );\n\n return (\n <>\n {child}\n {typeof document !== \"undefined\"\n ? createPortal(tooltip, document.body)\n : tooltip}\n </>\n );\n}\n"],"mappings":"yHA8CA,IAAM,EAAM,EAEZ,SAAS,EAAa,EAAyB,EAAiB,CACzD,KACL,IAAI,OAAO,GAAQ,WAAY,CAC7B,EAA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CAAE,WAAY,SAAU,IAAK,MAAO,KAAM,MAAO,UAGtD,EACG,CAAA,CAGR,OACE,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,CACG,EACA,OAAO,SAAa,KAAA,EAAA,EAAA,cACJ,EAAS,SAAS,KAAK,CACpC,EACH,CAAA,CAAA"}
|
|
@@ -4,7 +4,16 @@ import { createPortal as s } from "react-dom";
|
|
|
4
4
|
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/Tooltip/Tooltip.tsx
|
|
6
6
|
var d = 6;
|
|
7
|
-
function f(e, t
|
|
7
|
+
function f(e, t) {
|
|
8
|
+
if (e) {
|
|
9
|
+
if (typeof e == "function") {
|
|
10
|
+
e(t);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
e.current = t;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function p(e, t, n) {
|
|
8
17
|
let r = window.innerWidth, i = window.innerHeight, a = [
|
|
9
18
|
n,
|
|
10
19
|
n === "top" || n === "bottom" ? n === "top" ? "bottom" : "top" : n === "left" ? "right" : "left",
|
|
@@ -30,61 +39,63 @@ function f(e, t, n) {
|
|
|
30
39
|
placement: n
|
|
31
40
|
};
|
|
32
41
|
}
|
|
33
|
-
function
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
!
|
|
38
|
-
}, [
|
|
42
|
+
function m({ label: d, placement: m = "top", delay: h = 500, children: g }) {
|
|
43
|
+
let _ = i(), [v, y] = o(!1), [b, x] = o(null), S = a(null), C = a(null), w = a(null), T = () => {
|
|
44
|
+
w.current &&= (clearTimeout(w.current), null);
|
|
45
|
+
}, E = n(() => {
|
|
46
|
+
!S.current || !C.current || x(p(S.current.getBoundingClientRect(), C.current.getBoundingClientRect(), m));
|
|
47
|
+
}, [m]);
|
|
39
48
|
r(() => {
|
|
40
|
-
if (
|
|
49
|
+
if (v) return E(), window.addEventListener("scroll", E, {
|
|
41
50
|
passive: !0,
|
|
42
51
|
capture: !0
|
|
43
|
-
}), window.addEventListener("resize",
|
|
44
|
-
window.removeEventListener("scroll",
|
|
52
|
+
}), window.addEventListener("resize", E, { passive: !0 }), () => {
|
|
53
|
+
window.removeEventListener("scroll", E, { capture: !0 }), window.removeEventListener("resize", E);
|
|
45
54
|
};
|
|
46
|
-
}, [
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
}, [
|
|
50
|
-
|
|
55
|
+
}, [v, E]);
|
|
56
|
+
let D = n(() => {
|
|
57
|
+
T(), w.current = setTimeout(() => y(!0), h);
|
|
58
|
+
}, [h]), O = n(() => {
|
|
59
|
+
T(), y(!1), x(null);
|
|
51
60
|
}, []);
|
|
52
61
|
r(() => {
|
|
53
|
-
|
|
54
|
-
}, [
|
|
55
|
-
if (!
|
|
62
|
+
v && E();
|
|
63
|
+
}, [v, E]), r(() => {
|
|
64
|
+
if (!v) return;
|
|
56
65
|
let e = (e) => {
|
|
57
|
-
e.key === "Escape" &&
|
|
66
|
+
e.key === "Escape" && O();
|
|
58
67
|
};
|
|
59
68
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
60
|
-
}, [
|
|
61
|
-
let
|
|
62
|
-
ref:
|
|
63
|
-
|
|
69
|
+
}, [v, O]);
|
|
70
|
+
let k = g.props.ref, A = t(g, {
|
|
71
|
+
ref: (e) => {
|
|
72
|
+
S.current = e, f(k, e);
|
|
73
|
+
},
|
|
74
|
+
"aria-describedby": _,
|
|
64
75
|
onMouseEnter: (e) => {
|
|
65
|
-
|
|
76
|
+
D(), g.props.onMouseEnter?.(e);
|
|
66
77
|
},
|
|
67
78
|
onMouseLeave: (e) => {
|
|
68
|
-
|
|
79
|
+
O(), g.props.onMouseLeave?.(e);
|
|
69
80
|
},
|
|
70
81
|
onFocus: (e) => {
|
|
71
|
-
|
|
82
|
+
D(), g.props.onFocus?.(e);
|
|
72
83
|
},
|
|
73
84
|
onBlur: (e) => {
|
|
74
|
-
|
|
85
|
+
O(), g.props.onBlur?.(e);
|
|
75
86
|
}
|
|
76
|
-
}),
|
|
77
|
-
ref:
|
|
78
|
-
id:
|
|
87
|
+
}), j = /* @__PURE__ */ l("div", {
|
|
88
|
+
ref: C,
|
|
89
|
+
id: _,
|
|
79
90
|
role: "tooltip",
|
|
80
91
|
className: [
|
|
81
92
|
e.tooltip,
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
b ? e[b.placement] : null,
|
|
94
|
+
v && b ? e.visible : null
|
|
84
95
|
].filter(Boolean).join(" "),
|
|
85
|
-
style:
|
|
86
|
-
top:
|
|
87
|
-
left:
|
|
96
|
+
style: b ? {
|
|
97
|
+
top: b.top,
|
|
98
|
+
left: b.left
|
|
88
99
|
} : {
|
|
89
100
|
visibility: "hidden",
|
|
90
101
|
top: -9999,
|
|
@@ -92,9 +103,9 @@ function p({ label: d, placement: p = "top", delay: m = 500, children: h }) {
|
|
|
92
103
|
},
|
|
93
104
|
children: d
|
|
94
105
|
});
|
|
95
|
-
return /* @__PURE__ */ u(c, { children: [
|
|
106
|
+
return /* @__PURE__ */ u(c, { children: [A, typeof document < "u" ? s(j, document.body) : j] });
|
|
96
107
|
}
|
|
97
108
|
//#endregion
|
|
98
|
-
export {
|
|
109
|
+
export { m as Tooltip };
|
|
99
110
|
|
|
100
111
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":[],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\n useState,\n useRef,\n useId,\n useCallback,\n useEffect,\n cloneElement,\n type ReactElement,\n type HTMLAttributes,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport styles from \"./Tooltip.module.css\";\n\nexport type TooltipPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport interface TooltipProps {\n /**\n * The tooltip label. Keep it short — a noun phrase or brief description.\n * Do not duplicate information already visible on screen.\n */\n label: string;\n /**\n * Preferred placement relative to the trigger.\n * The tooltip flips automatically if there is not enough space.\n * Defaults to `\"top\"`.\n */\n placement?: TooltipPlacement;\n /**\n * Delay in milliseconds before the tooltip appears on hover.\n * Defaults to `500`. Set to `0` for instant.\n */\n delay?: number;\n /**\n * The element that triggers the tooltip.\n * Must be a single React element that can receive `ref` and event props.\n */\n children: ReactElement<HTMLAttributes<HTMLElement>>;\n}\n\ninterface Position {\n top: number;\n left: number;\n placement: TooltipPlacement;\n}\n\nconst GAP = 6; // px between trigger and tooltip\n\nfunction computePosition(\n trigger: DOMRect,\n tooltip: DOMRect,\n preferred: TooltipPlacement\n): Position {\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n\n const placements: TooltipPlacement[] = [\n preferred,\n preferred === \"top\" || preferred === \"bottom\"\n ? preferred === \"top\" ? \"bottom\" : \"top\"\n : preferred === \"left\" ? \"right\" : \"left\",\n \"top\",\n \"bottom\",\n \"left\",\n \"right\",\n ];\n\n for (const p of placements) {\n let top = 0;\n let left = 0;\n\n if (p === \"top\") {\n top = trigger.top - tooltip.height - GAP;\n left = trigger.left + trigger.width / 2 - tooltip.width / 2;\n } else if (p === \"bottom\") {\n top = trigger.bottom + GAP;\n left = trigger.left + trigger.width / 2 - tooltip.width / 2;\n } else if (p === \"left\") {\n top = trigger.top + trigger.height / 2 - tooltip.height / 2;\n left = trigger.left - tooltip.width - GAP;\n } else {\n top = trigger.top + trigger.height / 2 - tooltip.height / 2;\n left = trigger.right + GAP;\n }\n\n // Clamp to viewport with 8 px margin\n const margin = 8;\n const fitsH = left >= margin && left + tooltip.width <= vw - margin;\n const fitsV = top >= margin && top + tooltip.height <= vh - margin;\n\n if (fitsH && fitsV) {\n return {\n top: Math.max(margin, Math.min(top, vh - tooltip.height - margin)),\n left: Math.max(margin, Math.min(left, vw - tooltip.width - margin)),\n placement: p,\n };\n }\n }\n\n // Fallback: clamp preferred\n let top = 0, left = 0;\n if (preferred === \"top\") { top = trigger.top - tooltip.height - GAP; left = trigger.left + trigger.width / 2 - tooltip.width / 2; }\n if (preferred === \"bottom\") { top = trigger.bottom + GAP; left = trigger.left + trigger.width / 2 - tooltip.width / 2; }\n if (preferred === \"left\") { top = trigger.top + trigger.height / 2 - tooltip.height / 2; left = trigger.left - tooltip.width - GAP; }\n if (preferred === \"right\") { top = trigger.top + trigger.height / 2 - tooltip.height / 2; left = trigger.right + GAP; }\n\n const margin = 8;\n return {\n top: Math.max(margin, Math.min(top, vh - tooltip.height - margin)),\n left: Math.max(margin, Math.min(left, window.innerWidth - tooltip.width - margin)),\n placement: preferred,\n };\n}\n\n/**\n * Informational tooltip following the Adwaita / GNOME HIG pattern.\n *\n * Wraps a single trigger element and shows a floating label on hover or\n * keyboard focus. The tooltip is positioned automatically and flips if\n * there is not enough space.\n *\n * - `aria-describedby` is wired to the trigger automatically.\n * - The tooltip itself is `role=\"tooltip\"` and rendered in a portal.\n * - Does not show on touch — touch devices have no hover state.\n *\n * @example\n * <Tooltip label=\"Save file (Ctrl+S)\">\n * <Button aria-label=\"Save\"><Icon icon={Save} /></Button>\n * </Tooltip>\n *\n * @see https://developer.gnome.org/hig/patterns/feedback/tooltips.html\n */\nexport function Tooltip({\n label,\n placement: preferredPlacement = \"top\",\n delay = 500,\n children,\n}: TooltipProps) {\n const id = useId();\n const [visible, setVisible] = useState(false);\n const [pos, setPos] = useState<Position | null>(null);\n\n const triggerRef = useRef<HTMLElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const clearTimer = () => {\n if (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; }\n };\n\n const place = useCallback(() => {\n if (!triggerRef.current || !tooltipRef.current) return;\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const tooltipRect = tooltipRef.current.getBoundingClientRect();\n setPos(computePosition(triggerRect, tooltipRect, preferredPlacement));\n }, [preferredPlacement]);\n\n // Reposition on scroll/resize while visible\n useEffect(() => {\n if (!visible) return;\n place();\n window.addEventListener(\"scroll\", place, { passive: true, capture: true });\n window.addEventListener(\"resize\", place, { passive: true });\n return () => {\n window.removeEventListener(\"scroll\", place, { capture: true });\n window.removeEventListener(\"resize\", place);\n };\n }, [visible, place]);\n\n const show = useCallback(() => {\n clearTimer();\n timerRef.current = setTimeout(() => setVisible(true), delay);\n }, [delay]);\n\n const hide = useCallback(() => {\n clearTimer();\n setVisible(false);\n setPos(null);\n }, []);\n\n // Position as soon as the tooltip mounts\n useEffect(() => {\n if (visible) place();\n }, [visible, place]);\n\n // Dismiss on Escape\n useEffect(() => {\n if (!visible) return;\n const handler = (e: KeyboardEvent) => { if (e.key === \"Escape\") hide(); };\n document.addEventListener(\"keydown\", handler);\n return () => document.removeEventListener(\"keydown\", handler);\n }, [visible, hide]);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const child = cloneElement(children as any, {\n ref: triggerRef,\n \"aria-describedby\": id,\n onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n show();\n children.props.onMouseEnter?.(e);\n },\n onMouseLeave: (e: React.MouseEvent<HTMLElement>) => {\n hide();\n children.props.onMouseLeave?.(e);\n },\n onFocus: (e: React.FocusEvent<HTMLElement>) => {\n show();\n children.props.onFocus?.(e);\n },\n onBlur: (e: React.FocusEvent<HTMLElement>) => {\n hide();\n children.props.onBlur?.(e);\n },\n });\n\n const tooltip = (\n <div\n ref={tooltipRef}\n id={id}\n role=\"tooltip\"\n className={[\n styles.tooltip,\n pos ? styles[pos.placement] : null,\n visible && pos ? styles.visible : null,\n ]\n .filter(Boolean)\n .join(\" \")}\n style={\n pos\n ? { top: pos.top, left: pos.left }\n : { visibility: \"hidden\", top: -9999, left: -9999 }\n }\n >\n {label}\n </div>\n );\n\n return (\n <>\n {child}\n {typeof document !== \"undefined\"\n ? createPortal(tooltip, document.body)\n : tooltip}\n </>\n );\n}\n"],"mappings":";;;;;AA6CA,IAAM,IAAM;AAEZ,SAAS,EACP,GACA,GACA,GACU;CACV,IAAM,IAAK,OAA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AAC,EAEL,IAAO,QAAkB;AAG7B,EAFA,GAAY,EACZ,EAAW,GAAM,EACjB,EAAO,KAAK;IACX,EAAE,CAAC;AAQN,CALA,QAAgB;AACd,EAAI,KAAS,GAAO;IACnB,CAAC,GAAS,EAAM,CAAC,EAGpB,QAAgB;AACd,MAAI,CAAC,EAAS;EACd,IAAM,KAAW,MAAqB;AAAE,GAAI,EAAE,QAAQ,YAAU,GAAM;;AAEtE,SADA,SAAS,iBAAiB,WAAW,EAAQ,QAChC,SAAS,oBAAoB,WAAW,EAAQ;IAC5D,CAAC,GAAS,EAAK,CAAC;CAGnB,IAAM,IAAQ,EAAa,GAAiB;EAC1C,KAAK;EACL,oBAAoB;EACpB,eAAe,MAAqC;AAElD,GADA,GAAM,EACN,EAAS,MAAM,eAAe,EAAE;;EAElC,eAAe,MAAqC;AAElD,GADA,GAAM,EACN,EAAS,MAAM,eAAe,EAAE;;EAElC,UAAU,MAAqC;AAE7C,GADA,GAAM,EACN,EAAS,MAAM,UAAU,EAAE;;EAE7B,SAAS,MAAqC;AAE5C,GADA,GAAM,EACN,EAAS,MAAM,SAAS,EAAE;;EAE7B,CAAC,EAEI,IACJ,kBAAC,OAAD;EACE,KAAK;EACD;EACJ,MAAK;EACL,WAAW;GACT,EAAO;GACP,IAAM,EAAO,EAAI,aAAa;GAC9B,KAAW,IAAM,EAAO,UAAU;GACnC,CACE,OAAO,QAAQ,CACf,KAAK,IAAI;EACZ,OACE,IACI;GAAE,KAAK,EAAI;GAAK,MAAM,EAAI;GAAM,GAChC;GAAE,YAAY;GAAU,KAAK;GAAO,MAAM;GAAO;YAGtD;EACG,CAAA;AAGR,QACE,kBAAA,GAAA,EAAA,UAAA,CACG,GACA,OAAO,WAAa,MACjB,EAAa,GAAS,SAAS,KAAK,GACpC,EACH,EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":[],"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\n useState,\n useRef,\n useId,\n useCallback,\n useEffect,\n cloneElement,\n type ReactElement,\n type HTMLAttributes,\n type Ref,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport styles from \"./Tooltip.module.css\";\n\nexport type TooltipPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport interface TooltipProps {\n /**\n * The tooltip label. Keep it short — a noun phrase or brief description.\n * Do not duplicate information already visible on screen.\n */\n label: string;\n /**\n * Preferred placement relative to the trigger.\n * The tooltip flips automatically if there is not enough space.\n * Defaults to `\"top\"`.\n */\n placement?: TooltipPlacement;\n /**\n * Delay in milliseconds before the tooltip appears on hover.\n * Defaults to `500`. Set to `0` for instant.\n */\n delay?: number;\n /**\n * The element that triggers the tooltip.\n * Must be a single React element that can receive `ref` and event props.\n */\n children: ReactElement<HTMLAttributes<HTMLElement>>;\n}\n\ninterface Position {\n top: number;\n left: number;\n placement: TooltipPlacement;\n}\n\nconst GAP = 6; // px between trigger and tooltip\n\nfunction assignRef<T>(ref: Ref<T> | undefined, value: T | null) {\n if (!ref) return;\n if (typeof ref === \"function\") {\n ref(value);\n return;\n }\n ref.current = value;\n}\n\nfunction computePosition(\n trigger: DOMRect,\n tooltip: DOMRect,\n preferred: TooltipPlacement\n): Position {\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n\n const placements: TooltipPlacement[] = [\n preferred,\n preferred === \"top\" || preferred === \"bottom\"\n ? preferred === \"top\" ? \"bottom\" : \"top\"\n : preferred === \"left\" ? \"right\" : \"left\",\n \"top\",\n \"bottom\",\n \"left\",\n \"right\",\n ];\n\n for (const p of placements) {\n let top = 0;\n let left = 0;\n\n if (p === \"top\") {\n top = trigger.top - tooltip.height - GAP;\n left = trigger.left + trigger.width / 2 - tooltip.width / 2;\n } else if (p === \"bottom\") {\n top = trigger.bottom + GAP;\n left = trigger.left + trigger.width / 2 - tooltip.width / 2;\n } else if (p === \"left\") {\n top = trigger.top + trigger.height / 2 - tooltip.height / 2;\n left = trigger.left - tooltip.width - GAP;\n } else {\n top = trigger.top + trigger.height / 2 - tooltip.height / 2;\n left = trigger.right + GAP;\n }\n\n // Clamp to viewport with 8 px margin\n const margin = 8;\n const fitsH = left >= margin && left + tooltip.width <= vw - margin;\n const fitsV = top >= margin && top + tooltip.height <= vh - margin;\n\n if (fitsH && fitsV) {\n return {\n top: Math.max(margin, Math.min(top, vh - tooltip.height - margin)),\n left: Math.max(margin, Math.min(left, vw - tooltip.width - margin)),\n placement: p,\n };\n }\n }\n\n // Fallback: clamp preferred\n let top = 0, left = 0;\n if (preferred === \"top\") { top = trigger.top - tooltip.height - GAP; left = trigger.left + trigger.width / 2 - tooltip.width / 2; }\n if (preferred === \"bottom\") { top = trigger.bottom + GAP; left = trigger.left + trigger.width / 2 - tooltip.width / 2; }\n if (preferred === \"left\") { top = trigger.top + trigger.height / 2 - tooltip.height / 2; left = trigger.left - tooltip.width - GAP; }\n if (preferred === \"right\") { top = trigger.top + trigger.height / 2 - tooltip.height / 2; left = trigger.right + GAP; }\n\n const margin = 8;\n return {\n top: Math.max(margin, Math.min(top, vh - tooltip.height - margin)),\n left: Math.max(margin, Math.min(left, window.innerWidth - tooltip.width - margin)),\n placement: preferred,\n };\n}\n\n/**\n * Informational tooltip following the Adwaita / GNOME HIG pattern.\n *\n * Wraps a single trigger element and shows a floating label on hover or\n * keyboard focus. The tooltip is positioned automatically and flips if\n * there is not enough space.\n *\n * - `aria-describedby` is wired to the trigger automatically.\n * - The tooltip itself is `role=\"tooltip\"` and rendered in a portal.\n * - Does not show on touch — touch devices have no hover state.\n *\n * @example\n * <Tooltip label=\"Save file (Ctrl+S)\">\n * <Button aria-label=\"Save\"><Icon icon={Save} /></Button>\n * </Tooltip>\n *\n * @see https://developer.gnome.org/hig/patterns/feedback/tooltips.html\n */\nexport function Tooltip({\n label,\n placement: preferredPlacement = \"top\",\n delay = 500,\n children,\n}: TooltipProps) {\n const id = useId();\n const [visible, setVisible] = useState(false);\n const [pos, setPos] = useState<Position | null>(null);\n\n const triggerRef = useRef<HTMLElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const clearTimer = () => {\n if (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; }\n };\n\n const place = useCallback(() => {\n if (!triggerRef.current || !tooltipRef.current) return;\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const tooltipRect = tooltipRef.current.getBoundingClientRect();\n setPos(computePosition(triggerRect, tooltipRect, preferredPlacement));\n }, [preferredPlacement]);\n\n // Reposition on scroll/resize while visible\n useEffect(() => {\n if (!visible) return;\n place();\n window.addEventListener(\"scroll\", place, { passive: true, capture: true });\n window.addEventListener(\"resize\", place, { passive: true });\n return () => {\n window.removeEventListener(\"scroll\", place, { capture: true });\n window.removeEventListener(\"resize\", place);\n };\n }, [visible, place]);\n\n const show = useCallback(() => {\n clearTimer();\n timerRef.current = setTimeout(() => setVisible(true), delay);\n }, [delay]);\n\n const hide = useCallback(() => {\n clearTimer();\n setVisible(false);\n setPos(null);\n }, []);\n\n // Position as soon as the tooltip mounts\n useEffect(() => {\n if (visible) place();\n }, [visible, place]);\n\n // Dismiss on Escape\n useEffect(() => {\n if (!visible) return;\n const handler = (e: KeyboardEvent) => { if (e.key === \"Escape\") hide(); };\n document.addEventListener(\"keydown\", handler);\n return () => document.removeEventListener(\"keydown\", handler);\n }, [visible, hide]);\n\n const childRef = (children.props as HTMLAttributes<HTMLElement> & {\n ref?: Ref<HTMLElement>;\n }).ref;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const child = cloneElement(children as any, {\n ref: (node: HTMLElement | null) => {\n triggerRef.current = node;\n assignRef(childRef, node);\n },\n \"aria-describedby\": id,\n onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n show();\n children.props.onMouseEnter?.(e);\n },\n onMouseLeave: (e: React.MouseEvent<HTMLElement>) => {\n hide();\n children.props.onMouseLeave?.(e);\n },\n onFocus: (e: React.FocusEvent<HTMLElement>) => {\n show();\n children.props.onFocus?.(e);\n },\n onBlur: (e: React.FocusEvent<HTMLElement>) => {\n hide();\n children.props.onBlur?.(e);\n },\n });\n\n const tooltip = (\n <div\n ref={tooltipRef}\n id={id}\n role=\"tooltip\"\n className={[\n styles.tooltip,\n pos ? styles[pos.placement] : null,\n visible && pos ? styles.visible : null,\n ]\n .filter(Boolean)\n .join(\" \")}\n style={\n pos\n ? { top: pos.top, left: pos.left }\n : { visibility: \"hidden\", top: -9999, left: -9999 }\n }\n >\n {label}\n </div>\n );\n\n return (\n <>\n {child}\n {typeof document !== \"undefined\"\n ? createPortal(tooltip, document.body)\n : tooltip}\n </>\n );\n}\n"],"mappings":";;;;;AA8CA,IAAM,IAAM;AAEZ,SAAS,EAAa,GAAyB,GAAiB;AACzD,QACL;MAAI,OAAO,KAAQ,YAAY;AAC7B,KAAI,EAAM;AACV;;AAEF,IAAI,UAAU;;;AAGhB,SAAS,EACP,GACA,GACA,GACU;CACV,IAAM,IAAK,OAAO,YACZ,IAAK,OAAO,aAEZ,IAAiC;EACrC;EACA,MAAc,SAAS,MAAc,WACjC,MAAc,QAAQ,WAAW,QACjC,MAAc,SAAS,UAAU;EACrC;EACA;EACA;EACA;EACD;AAED,MAAK,IAAM,KAAK,GAAY;EAC1B,IAAI,IAAM,GACN,IAAO;AAEX,EAAI,MAAM,SACR,IAAO,EAAQ,MAAO,EAAQ,SAAS,GACvC,IAAO,EAAQ,OAAO,EAAQ,QAAQ,IAAI,EAAQ,QAAQ,KACjD,MAAM,YACf,IAAO,EAAQ,SAAS,GACxB,IAAO,EAAQ,OAAS,EAAQ,QAAQ,IAAI,EAAQ,QAAQ,KACnD,MAAM,UACf,IAAO,EAAQ,MAAO,EAAQ,SAAS,IAAI,EAAQ,SAAS,GAC5D,IAAO,EAAQ,OAAO,EAAQ,QAAQ,MAEtC,IAAO,EAAQ,MAAS,EAAQ,SAAS,IAAI,EAAQ,SAAS,GAC9D,IAAO,EAAQ,QAAS;EAI1B,IACM,IAAQ,KAAQ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AAM,eAAe,EAAE;;EAElC,UAAU,MAAqC;AAE7C,GADA,GAAM,EACN,EAAS,MAAM,UAAU,EAAE;;EAE7B,SAAS,MAAqC;AAE5C,GADA,GAAM,EACN,EAAS,MAAM,SAAS,EAAE;;EAE7B,CAAC,EAEI,IACJ,kBAAC,OAAD;EACE,KAAK;EACD;EACJ,MAAK;EACL,WAAW;GACT,EAAO;GACP,IAAM,EAAO,EAAI,aAAa;GAC9B,KAAW,IAAM,EAAO,UAAU;GACnC,CACE,OAAO,QAAQ,CACf,KAAK,IAAI;EACZ,OACE,IACI;GAAE,KAAK,EAAI;GAAK,MAAM,EAAI;GAAM,GAChC;GAAE,YAAY;GAAU,KAAK;GAAO,MAAM;GAAO;YAGtD;EACG,CAAA;AAGR,QACE,kBAAA,GAAA,EAAA,UAAA,CACG,GACA,OAAO,WAAa,MACjB,EAAa,GAAS,SAAS,KAAK,GACpC,EACH,EAAA,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./components/AboutDialog/AboutDialog.cjs`),t=require(`./components/ActionRow/ActionRow.cjs`),n=require(`./components/Avatar/Avatar.cjs`),r=require(`./components/Badge/Badge.cjs`),i=require(`./components/Banner/Banner.cjs`),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./components/AboutDialog/AboutDialog.cjs`),t=require(`./components/ActionRow/ActionRow.cjs`),n=require(`./components/Avatar/Avatar.cjs`),r=require(`./components/Badge/Badge.cjs`),i=require(`./components/Banner/Banner.cjs`),ee=require(`./components/Bin/Bin.cjs`),a=require(`./components/Blockquote/Blockquote.cjs`),o=require(`./components/BottomSheet/BottomSheet.cjs`),s=require(`./components/Box/Box.cjs`),c=require(`./components/Separator/Separator.cjs`),l=require(`./components/BoxedList/BoxedList.cjs`),u=require(`./components/BreakpointBin/BreakpointBin.cjs`),d=require(`./components/Button/Button.cjs`),f=require(`./components/ButtonContent/ButtonContent.cjs`),p=require(`./components/ButtonRow/ButtonRow.cjs`),m=require(`./components/Card/Card.cjs`),h=require(`./components/Carousel/Carousel.cjs`),g=require(`./components/CheckRow/CheckRow.cjs`),_=require(`./components/Checkbox/Checkbox.cjs`),v=require(`./components/Icon/Icon.cjs`),y=require(`./components/Chip/Chip.cjs`),b=require(`./components/Clamp/Clamp.cjs`),x=require(`./components/ColumnView/ColumnView.cjs`),S=require(`./components/ComboRow/ComboRow.cjs`),C=require(`./components/ContributionGraph/ContributionGraph.cjs`),w=require(`./components/CountDownTimer/CountDownTimer.cjs`),T=require(`./components/Dialog/Dialog.cjs`),E=require(`./components/Dropdown/Dropdown.cjs`),D=require(`./components/EntryRow/EntryRow.cjs`),O=require(`./components/ExpanderRow/ExpanderRow.cjs`),k=require(`./components/Footer/Footer.cjs`),A=require(`./components/Frame/Frame.cjs`),j=require(`./components/HeaderBar/HeaderBar.cjs`),M=require(`./components/Tooltip/Tooltip.cjs`),N=require(`./components/IconButton/IconButton.cjs`),P=require(`./components/InlineViewSwitcher/InlineViewSwitcher.cjs`),F=require(`./components/InlineViewSwitcher/InlineViewSwitcherItem.cjs`),I=require(`./components/Link/Link.cjs`),L=require(`./components/LinkedGroup/LinkedGroup.cjs`),R=require(`./hooks/useBreakpoint.cjs`),z=require(`./components/NavigationSplitView/NavigationSplitView.cjs`),B=require(`./components/NavigationView/NavigationView.cjs`),V=require(`./components/OverlaySplitView/OverlaySplitView.cjs`),H=require(`./components/PasswordEntryRow/PasswordEntryRow.cjs`),U=require(`./components/PathBar/PathBar.cjs`),W=require(`./components/Popover/Popover.cjs`),G=require(`./components/PreferencesDialog/PreferencesDialog.cjs`),K=require(`./components/PreferencesGroup/PreferencesGroup.cjs`),q=require(`./components/PreferencesPage/PreferencesPage.cjs`),te=require(`./components/ProgressBar/ProgressBar.cjs`),J=require(`./components/RadioButton/RadioButton.cjs`),Y=require(`./components/Spinner/Spinner.cjs`),X=require(`./components/SearchBar/SearchBar.cjs`),Z=require(`./components/ShortcutLabel/ShortcutLabel.cjs`),Q=require(`./components/ShortcutsDialog/ShortcutsDialog.cjs`),ne=require(`./components/StatusPage/StatusPage.cjs`),$=require(`./components/Sidebar/Sidebar.cjs`),re=require(`./components/Sidebar/SidebarSection.cjs`),ie=require(`./components/Sidebar/SidebarItem.cjs`),ae=require(`./components/Skeleton/Skeleton.cjs`),oe=require(`./components/Slider/Slider.cjs`),se=require(`./components/SpinButton/SpinButton.cjs`),ce=require(`./components/SpinRow/SpinRow.cjs`),le=require(`./components/SplitButton/SplitButton.cjs`),ue=require(`./components/StatusBadge/StatusBadge.cjs`),de=require(`./components/Switch/Switch.cjs`),fe=require(`./components/SwitchRow/SwitchRow.cjs`),pe=require(`./components/Tabs/TabBar.cjs`),me=require(`./components/Tabs/TabItem.cjs`),he=require(`./components/Tabs/TabPanel.cjs`),ge=require(`./components/TerminalView/TerminalView.cjs`),_e=require(`./components/Text/Text.cjs`),ve=require(`./components/TextField/TextField.cjs`),ye=require(`./components/Timeline/Timeline.cjs`),be=require(`./components/Toast/Toast.cjs`),xe=require(`./components/Toast/Toaster.cjs`),Se=require(`./components/ToggleGroup/ToggleGroup.cjs`),Ce=require(`./components/ToggleGroup/ToggleGroupItem.cjs`),we=require(`./components/Toolbar/Toolbar.cjs`),Te=require(`./components/Toolbar/Spacer.cjs`),Ee=require(`./components/ToolbarView/ToolbarView.cjs`),De=require(`./components/ViewSwitcher/ViewSwitcher.cjs`),Oe=require(`./components/ViewSwitcher/ViewSwitcherItem.cjs`),ke=require(`./components/ViewSwitcherBar/ViewSwitcherBar.cjs`),Ae=require(`./components/ViewSwitcherSidebar/ViewSwitcherSidebar.cjs`),je=require(`./components/ViewSwitcherSidebar/ViewSwitcherSidebarItem.cjs`),Me=require(`./components/WindowTitle/WindowTitle.cjs`),Ne=require(`./components/WrapBox/WrapBox.cjs`);exports.AboutDialog=e.AboutDialog,exports.ActionRow=t.ActionRow,exports.Avatar=n.Avatar,exports.Badge=r.Badge,exports.Banner=i.Banner,exports.Bin=ee.Bin,exports.Blockquote=a.Blockquote,exports.BottomSheet=o.BottomSheet,exports.Box=s.Box,exports.BoxedList=l.BoxedList,exports.BreakpointBin=u.BreakpointBin,exports.Button=d.Button,exports.ButtonContent=f.ButtonContent,exports.ButtonRow=p.ButtonRow,exports.Card=m.Card,exports.Carousel=h.Carousel,exports.CarouselIndicatorDots=h.CarouselIndicatorDots,exports.CarouselIndicatorLines=h.CarouselIndicatorLines,exports.CheckRow=g.CheckRow,exports.Checkbox=_.Checkbox,exports.Chip=y.Chip,exports.Clamp=b.Clamp,exports.ColumnView=x.ColumnView,exports.ComboRow=S.ComboRow,exports.ContributionGraph=C.ContributionGraph,exports.CountDownTimer=w.CountDownTimer,exports.Dialog=T.Dialog,exports.Dropdown=E.Dropdown,exports.EntryRow=D.EntryRow,exports.ExpanderRow=O.ExpanderRow,exports.Footer=k.Footer,exports.Frame=A.Frame,exports.GNOME_BREAKPOINTS=R.GNOME_BREAKPOINTS,exports.HeaderBar=j.HeaderBar,exports.Icon=v.Icon,exports.IconButton=N.IconButton,exports.InlineViewSwitcher=P.InlineViewSwitcher,exports.InlineViewSwitcherItem=F.InlineViewSwitcherItem,exports.Link=I.Link,exports.LinkedGroup=L.LinkedGroup,exports.NavigationPage=B.NavigationPage,exports.NavigationSplitView=z.NavigationSplitView,exports.NavigationView=B.NavigationView,exports.OverlaySplitView=V.OverlaySplitView,exports.PasswordEntryRow=H.PasswordEntryRow,exports.PathBar=U.PathBar,exports.Popover=W.Popover,exports.PreferencesDialog=G.PreferencesDialog,exports.PreferencesGroup=K.PreferencesGroup,exports.PreferencesPage=q.PreferencesPage,exports.ProgressBar=te.ProgressBar,exports.RadioButton=J.RadioButton,exports.SearchBar=X.SearchBar,exports.Separator=c.Separator,exports.ShortcutLabel=Z.ShortcutLabel,exports.ShortcutsDialog=Q.ShortcutsDialog,exports.Sidebar=$.Sidebar,exports.SidebarCollapsedContext=$.SidebarCollapsedContext,exports.SidebarItem=ie.SidebarItem,exports.SidebarSection=re.SidebarSection,exports.Skeleton=ae.Skeleton,exports.Slider=oe.Slider,exports.Spacer=Te.Spacer,exports.SpinButton=se.SpinButton,exports.SpinRow=ce.SpinRow,exports.Spinner=Y.Spinner,exports.SplitButton=le.SplitButton,exports.StatusBadge=ue.StatusBadge,exports.StatusPage=ne.StatusPage,exports.Switch=de.Switch,exports.SwitchRow=fe.SwitchRow,exports.TabBar=pe.TabBar,exports.TabItem=me.TabItem,exports.TabPanel=he.TabPanel,exports.TerminalView=ge.TerminalView,exports.Text=_e.Text,exports.TextField=ve.TextField,exports.Timeline=ye.Timeline,exports.Toast=be.Toast,exports.Toaster=xe.Toaster,exports.ToggleGroup=Se.ToggleGroup,exports.ToggleGroupItem=Ce.ToggleGroupItem,exports.Toolbar=we.Toolbar,exports.ToolbarView=Ee.ToolbarView,exports.Tooltip=M.Tooltip,exports.ViewSwitcher=De.ViewSwitcher,exports.ViewSwitcherBar=ke.ViewSwitcherBar,exports.ViewSwitcherItem=Oe.ViewSwitcherItem,exports.ViewSwitcherSidebar=Ae.ViewSwitcherSidebar,exports.ViewSwitcherSidebarItem=je.ViewSwitcherSidebarItem,exports.WindowTitle=Me.WindowTitle,exports.WrapBox=Ne.WrapBox,exports.useBreakpoint=R.useBreakpoint,exports.useNavigation=B.useNavigation,exports.useSidebarCollapsed=$.useSidebarCollapsed;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export { Card } from './components/Card';
|
|
|
8
8
|
export type { CardProps, CardPadding } from './components/Card';
|
|
9
9
|
export { Spinner } from './components/Spinner';
|
|
10
10
|
export type { SpinnerProps, SpinnerSize } from './components/Spinner';
|
|
11
|
+
export { Skeleton } from './components/Skeleton';
|
|
12
|
+
export type { SkeletonProps, SkeletonVariant } from './components/Skeleton';
|
|
11
13
|
export { Avatar } from './components/Avatar';
|
|
12
14
|
export type { AvatarProps, AvatarSize, AvatarColor } from './components/Avatar';
|
|
13
15
|
export { Separator } from './components/Separator';
|
|
@@ -34,6 +36,8 @@ export { CountDownTimer } from './components/CountDownTimer';
|
|
|
34
36
|
export type { CountDownTimerProps, CountDownVariant } from './components/CountDownTimer';
|
|
35
37
|
export { Icon } from './components/Icon';
|
|
36
38
|
export type { IconProps, IconSize } from './components/Icon';
|
|
39
|
+
export { IconButton } from './components/IconButton';
|
|
40
|
+
export type { IconButtonProps, IconButtonSize, IconButtonVariant } from './components/IconButton';
|
|
37
41
|
export { Sidebar, SidebarSection, SidebarItem, SidebarCollapsedContext, useSidebarCollapsed } from './components/Sidebar';
|
|
38
42
|
export type { SidebarProps, SidebarSectionProps, SidebarItemProps, SidebarMenuEntry } from './components/Sidebar';
|
|
39
43
|
export { SpinButton } from './components/SpinButton';
|
package/dist/index.js
CHANGED
|
@@ -31,57 +31,59 @@ import { ExpanderRow as j } from "./components/ExpanderRow/ExpanderRow.js";
|
|
|
31
31
|
import { Footer as M } from "./components/Footer/Footer.js";
|
|
32
32
|
import { Frame as N } from "./components/Frame/Frame.js";
|
|
33
33
|
import { HeaderBar as P } from "./components/HeaderBar/HeaderBar.js";
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import {
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
import {
|
|
87
|
-
|
|
34
|
+
import { Tooltip as F } from "./components/Tooltip/Tooltip.js";
|
|
35
|
+
import { IconButton as I } from "./components/IconButton/IconButton.js";
|
|
36
|
+
import { InlineViewSwitcher as L } from "./components/InlineViewSwitcher/InlineViewSwitcher.js";
|
|
37
|
+
import { InlineViewSwitcherItem as R } from "./components/InlineViewSwitcher/InlineViewSwitcherItem.js";
|
|
38
|
+
import { Link as z } from "./components/Link/Link.js";
|
|
39
|
+
import { LinkedGroup as B } from "./components/LinkedGroup/LinkedGroup.js";
|
|
40
|
+
import { GNOME_BREAKPOINTS as V, useBreakpoint as H } from "./hooks/useBreakpoint.js";
|
|
41
|
+
import { NavigationSplitView as U } from "./components/NavigationSplitView/NavigationSplitView.js";
|
|
42
|
+
import { NavigationPage as W, NavigationView as G, useNavigation as K } from "./components/NavigationView/NavigationView.js";
|
|
43
|
+
import { OverlaySplitView as q } from "./components/OverlaySplitView/OverlaySplitView.js";
|
|
44
|
+
import { PasswordEntryRow as J } from "./components/PasswordEntryRow/PasswordEntryRow.js";
|
|
45
|
+
import { PathBar as Y } from "./components/PathBar/PathBar.js";
|
|
46
|
+
import { Popover as X } from "./components/Popover/Popover.js";
|
|
47
|
+
import { PreferencesDialog as Z } from "./components/PreferencesDialog/PreferencesDialog.js";
|
|
48
|
+
import { PreferencesGroup as Q } from "./components/PreferencesGroup/PreferencesGroup.js";
|
|
49
|
+
import { PreferencesPage as $ } from "./components/PreferencesPage/PreferencesPage.js";
|
|
50
|
+
import { ProgressBar as ee } from "./components/ProgressBar/ProgressBar.js";
|
|
51
|
+
import { RadioButton as te } from "./components/RadioButton/RadioButton.js";
|
|
52
|
+
import { Spinner as ne } from "./components/Spinner/Spinner.js";
|
|
53
|
+
import { SearchBar as re } from "./components/SearchBar/SearchBar.js";
|
|
54
|
+
import { ShortcutLabel as ie } from "./components/ShortcutLabel/ShortcutLabel.js";
|
|
55
|
+
import { ShortcutsDialog as ae } from "./components/ShortcutsDialog/ShortcutsDialog.js";
|
|
56
|
+
import { StatusPage as oe } from "./components/StatusPage/StatusPage.js";
|
|
57
|
+
import { Sidebar as se, SidebarCollapsedContext as ce, useSidebarCollapsed as le } from "./components/Sidebar/Sidebar.js";
|
|
58
|
+
import { SidebarSection as ue } from "./components/Sidebar/SidebarSection.js";
|
|
59
|
+
import { SidebarItem as de } from "./components/Sidebar/SidebarItem.js";
|
|
60
|
+
import { Skeleton as fe } from "./components/Skeleton/Skeleton.js";
|
|
61
|
+
import { Slider as pe } from "./components/Slider/Slider.js";
|
|
62
|
+
import { SpinButton as me } from "./components/SpinButton/SpinButton.js";
|
|
63
|
+
import { SpinRow as he } from "./components/SpinRow/SpinRow.js";
|
|
64
|
+
import { SplitButton as ge } from "./components/SplitButton/SplitButton.js";
|
|
65
|
+
import { StatusBadge as _e } from "./components/StatusBadge/StatusBadge.js";
|
|
66
|
+
import { Switch as ve } from "./components/Switch/Switch.js";
|
|
67
|
+
import { SwitchRow as ye } from "./components/SwitchRow/SwitchRow.js";
|
|
68
|
+
import { TabBar as be } from "./components/Tabs/TabBar.js";
|
|
69
|
+
import { TabItem as xe } from "./components/Tabs/TabItem.js";
|
|
70
|
+
import { TabPanel as Se } from "./components/Tabs/TabPanel.js";
|
|
71
|
+
import { TerminalView as Ce } from "./components/TerminalView/TerminalView.js";
|
|
72
|
+
import { Text as we } from "./components/Text/Text.js";
|
|
73
|
+
import { TextField as Te } from "./components/TextField/TextField.js";
|
|
74
|
+
import { Timeline as Ee } from "./components/Timeline/Timeline.js";
|
|
75
|
+
import { Toast as De } from "./components/Toast/Toast.js";
|
|
76
|
+
import { Toaster as Oe } from "./components/Toast/Toaster.js";
|
|
77
|
+
import { ToggleGroup as ke } from "./components/ToggleGroup/ToggleGroup.js";
|
|
78
|
+
import { ToggleGroupItem as Ae } from "./components/ToggleGroup/ToggleGroupItem.js";
|
|
79
|
+
import { Toolbar as je } from "./components/Toolbar/Toolbar.js";
|
|
80
|
+
import { Spacer as Me } from "./components/Toolbar/Spacer.js";
|
|
81
|
+
import { ToolbarView as Ne } from "./components/ToolbarView/ToolbarView.js";
|
|
82
|
+
import { ViewSwitcher as Pe } from "./components/ViewSwitcher/ViewSwitcher.js";
|
|
83
|
+
import { ViewSwitcherItem as Fe } from "./components/ViewSwitcher/ViewSwitcherItem.js";
|
|
84
|
+
import { ViewSwitcherBar as Ie } from "./components/ViewSwitcherBar/ViewSwitcherBar.js";
|
|
85
|
+
import { ViewSwitcherSidebar as Le } from "./components/ViewSwitcherSidebar/ViewSwitcherSidebar.js";
|
|
86
|
+
import { ViewSwitcherSidebarItem as Re } from "./components/ViewSwitcherSidebar/ViewSwitcherSidebarItem.js";
|
|
87
|
+
import { WindowTitle as ze } from "./components/WindowTitle/WindowTitle.js";
|
|
88
|
+
import { WrapBox as Be } from "./components/WrapBox/WrapBox.js";
|
|
89
|
+
export { e as AboutDialog, t as ActionRow, n as Avatar, r as Badge, i as Banner, a as Bin, o as Blockquote, s as BottomSheet, c as Box, u as BoxedList, d as BreakpointBin, f as Button, p as ButtonContent, m as ButtonRow, h as Card, g as Carousel, _ as CarouselIndicatorDots, v as CarouselIndicatorLines, y as CheckRow, b as Checkbox, S as Chip, C as Clamp, w as ColumnView, T as ComboRow, E as ContributionGraph, D as CountDownTimer, O as Dialog, k as Dropdown, A as EntryRow, j as ExpanderRow, M as Footer, N as Frame, V as GNOME_BREAKPOINTS, P as HeaderBar, x as Icon, I as IconButton, L as InlineViewSwitcher, R as InlineViewSwitcherItem, z as Link, B as LinkedGroup, W as NavigationPage, U as NavigationSplitView, G as NavigationView, q as OverlaySplitView, J as PasswordEntryRow, Y as PathBar, X as Popover, Z as PreferencesDialog, Q as PreferencesGroup, $ as PreferencesPage, ee as ProgressBar, te as RadioButton, re as SearchBar, l as Separator, ie as ShortcutLabel, ae as ShortcutsDialog, se as Sidebar, ce as SidebarCollapsedContext, de as SidebarItem, ue as SidebarSection, fe as Skeleton, pe as Slider, Me as Spacer, me as SpinButton, he as SpinRow, ne as Spinner, ge as SplitButton, _e as StatusBadge, oe as StatusPage, ve as Switch, ye as SwitchRow, be as TabBar, xe as TabItem, Se as TabPanel, Ce as TerminalView, we as Text, Te as TextField, Ee as Timeline, De as Toast, Oe as Toaster, ke as ToggleGroup, Ae as ToggleGroupItem, je as Toolbar, Ne as ToolbarView, F as Tooltip, Pe as ViewSwitcher, Ie as ViewSwitcherBar, Fe as ViewSwitcherItem, Le as ViewSwitcherSidebar, Re as ViewSwitcherSidebarItem, ze as WindowTitle, Be as WrapBox, H as useBreakpoint, K as useNavigation, le as useSidebarCollapsed };
|