@omer-x/tailwind-ui-kit 1.0.0-alpha.41 → 1.0.0-alpha.43

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.
Files changed (49) hide show
  1. package/README.md +279 -1
  2. package/dist/components/feedback/BaseToast.d.ts +72 -0
  3. package/dist/components/feedback/BaseToast.js +49 -0
  4. package/dist/components/feedback/BaseToastAction.d.ts +14 -0
  5. package/dist/components/feedback/BaseToastAction.js +10 -0
  6. package/dist/components/feedback/BaseToastArrow.d.ts +18 -0
  7. package/dist/components/feedback/BaseToastArrow.js +10 -0
  8. package/dist/components/feedback/BaseToastClose.d.ts +14 -0
  9. package/dist/components/feedback/BaseToastClose.js +10 -0
  10. package/dist/components/feedback/BaseToastContent.d.ts +17 -0
  11. package/dist/components/feedback/BaseToastContent.js +14 -0
  12. package/dist/components/feedback/BaseToastDescription.d.ts +12 -0
  13. package/dist/components/feedback/BaseToastDescription.js +10 -0
  14. package/dist/components/feedback/BaseToastTitle.d.ts +15 -0
  15. package/dist/components/feedback/BaseToastTitle.js +10 -0
  16. package/dist/components/feedback/BaseToastViewport.d.ts +21 -0
  17. package/dist/components/feedback/BaseToastViewport.js +24 -0
  18. package/dist/components/feedback/createToastManager.d.ts +6 -0
  19. package/dist/components/feedback/createToastManager.js +10 -0
  20. package/dist/components/feedback/index.d.ts +9 -0
  21. package/dist/components/feedback/index.js +4 -0
  22. package/dist/components/feedback/toastStyles.d.ts +2 -0
  23. package/dist/components/feedback/toastStyles.js +47 -0
  24. package/dist/components/feedback/toastTypes.d.ts +81 -0
  25. package/dist/components/feedback/toastTypes.js +1 -0
  26. package/dist/components/feedback/useToast.d.ts +7 -0
  27. package/dist/components/feedback/useToast.js +8 -0
  28. package/dist/components/menu/menuTypes.d.ts +1 -1
  29. package/dist/components/overlay/BaseTooltip.d.ts +92 -0
  30. package/dist/components/overlay/BaseTooltip.js +24 -0
  31. package/dist/components/overlay/BaseTooltipArrow.d.ts +20 -0
  32. package/dist/components/overlay/BaseTooltipArrow.js +10 -0
  33. package/dist/components/overlay/BaseTooltipPopup.d.ts +106 -0
  34. package/dist/components/overlay/BaseTooltipPopup.js +38 -0
  35. package/dist/components/overlay/BaseTooltipTrigger.d.ts +31 -0
  36. package/dist/components/overlay/BaseTooltipTrigger.js +14 -0
  37. package/dist/components/overlay/BaseTooltipViewport.d.ts +20 -0
  38. package/dist/components/overlay/BaseTooltipViewport.js +11 -0
  39. package/dist/components/overlay/createTooltipHandle.d.ts +30 -0
  40. package/dist/components/overlay/createTooltipHandle.js +27 -0
  41. package/dist/components/overlay/index.d.ts +7 -0
  42. package/dist/components/overlay/index.js +3 -0
  43. package/dist/components/providers/ToastProvider.d.ts +23 -0
  44. package/dist/components/providers/ToastProvider.js +13 -0
  45. package/dist/components/providers/TooltipProvider.d.ts +19 -0
  46. package/dist/components/providers/TooltipProvider.js +10 -0
  47. package/dist/components/providers/index.d.ts +3 -0
  48. package/dist/components/providers/index.js +3 -0
  49. package/package.json +13 -1
@@ -0,0 +1,6 @@
1
+ import { ToastManager } from "./toastTypes.js";
2
+ /**
3
+ * Creates a toast manager to show toasts from outside React (e.g. a fetch wrapper).
4
+ * Pass it to `ToastProvider`'s `manager`. Calls are ignored while no provider uses it.
5
+ */
6
+ export default function createToastManager<Data extends object = object>(): ToastManager<Data>;
@@ -0,0 +1,10 @@
1
+ import { Toast } from "@base-ui/react/toast";
2
+ // src/components/feedback/createToastManager.ts
3
+ /**
4
+ * Creates a toast manager to show toasts from outside React (e.g. a fetch wrapper).
5
+ * Pass it to `ToastProvider`'s `manager`. Calls are ignored while no provider uses it.
6
+ */
7
+ function createToastManager() {
8
+ return Toast.createToastManager();
9
+ }
10
+ export { createToastManager as default };
@@ -0,0 +1,9 @@
1
+ import _default, { ToastPositionerState, ToastState } from "./BaseToast.js";
2
+ import createToastManager from "./createToastManager.js";
3
+ import useToast, { UseToastReturn } from "./useToast.js";
4
+ import { ToastArrowState } from "./BaseToastArrow.js";
5
+ import { ToastContentState } from "./BaseToastContent.js";
6
+ import { ToastPartState } from "./BaseToastTitle.js";
7
+ import { ToastViewportState } from "./BaseToastViewport.js";
8
+ import { ToastAlign, ToastManager, ToastObject, ToastOptions, ToastPositionerOptions, ToastPromiseOptions, ToastSide, ToastSwipeDirection, ToastUpdate } from "./toastTypes.js";
9
+ export { _default as BaseToast, type ToastAlign, type ToastArrowState, type ToastContentState, type ToastManager, type ToastObject, type ToastOptions, type ToastPartState, type ToastPositionerOptions, type ToastPositionerState, type ToastPromiseOptions, type ToastSide, type ToastState, type ToastSwipeDirection, type ToastUpdate, type ToastViewportState, type UseToastReturn, createToastManager, useToast };
@@ -0,0 +1,4 @@
1
+ import BaseToast_default from "./BaseToast.js";
2
+ import createToastManager from "./createToastManager.js";
3
+ import useToast from "./useToast.js";
4
+ export { BaseToast_default as BaseToast, createToastManager, useToast };
@@ -0,0 +1,2 @@
1
+ export declare const stackedToastClassName: string[];
2
+ export declare const anchoredToastClassName: string[];
@@ -0,0 +1,47 @@
1
+ // src/components/feedback/toastStyles.ts
2
+ const stackedToastClassName = [
3
+ "absolute",
4
+ "right-0",
5
+ "bottom-0",
6
+ "w-full",
7
+ "origin-bottom",
8
+ "select-none",
9
+ "[--gap:0.75rem]",
10
+ "[--peek:0.75rem]",
11
+ "[--scale:max(0,1-var(--toast-index)*0.1)]",
12
+ "[--shrink:calc(1-var(--scale))]",
13
+ "[--height:var(--toast-frontmost-height,var(--toast-height))]",
14
+ "[--offset-y:calc(var(--toast-offset-y)*-1-var(--toast-index)*var(--gap)+var(--toast-swipe-movement-y))]",
15
+ "z-[calc(1000-var(--toast-index))]",
16
+ "h-(--height)",
17
+ "data-expanded:h-(--toast-height)",
18
+ "[transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-var(--toast-index)*var(--peek)-var(--shrink)*var(--height)))_scale(var(--scale))]",
19
+ "data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]",
20
+ "after:absolute",
21
+ "after:top-full",
22
+ "after:left-0",
23
+ "after:h-[calc(var(--gap)+1px)]",
24
+ "after:w-full",
25
+ "after:content-['']",
26
+ "transition-[transform,opacity,height]",
27
+ "duration-500",
28
+ "ease-[cubic-bezier(0.22,1,0.36,1)]",
29
+ "data-limited:opacity-0",
30
+ "data-starting-style:[transform:translateY(150%)]",
31
+ "data-ending-style:opacity-0",
32
+ "[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]",
33
+ "data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
34
+ "data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
35
+ "data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
36
+ "data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]"
37
+ ];
38
+ const anchoredToastClassName = [
39
+ "origin-(--transform-origin)",
40
+ "transition-[scale,opacity]",
41
+ "duration-150",
42
+ "data-ending-style:scale-90",
43
+ "data-ending-style:opacity-0",
44
+ "data-starting-style:scale-90",
45
+ "data-starting-style:opacity-0"
46
+ ];
47
+ export { anchoredToastClassName, stackedToastClassName };
@@ -0,0 +1,81 @@
1
+ import { ComponentPropsWithoutRef, ReactNode } from "react";
2
+ export type ToastSide = "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end";
3
+ export type ToastAlign = "start" | "center" | "end";
4
+ export type ToastSwipeDirection = "up" | "down" | "left" | "right";
5
+ /** Places a toast against an element instead of stacking it in the viewport. */
6
+ export type ToastPositionerOptions = {
7
+ /** The element the toast is placed against. Setting it makes the toast anchored. */
8
+ anchor?: Element | null;
9
+ /** The side of the anchor the toast is placed on. It flips when there's no room. @default "top" */
10
+ side?: ToastSide;
11
+ /** How the toast is aligned to that side. @default "center" */
12
+ align?: ToastAlign;
13
+ /** The gap between the anchor and the toast, in pixels. @default 0 */
14
+ sideOffset?: number;
15
+ /** Moves the toast along the anchor's side, in pixels. @default 0 */
16
+ alignOffset?: number;
17
+ /** The space kept between the toast and the edges of the viewport, in pixels. @default 5 */
18
+ collisionPadding?: number | {
19
+ top?: number;
20
+ right?: number;
21
+ bottom?: number;
22
+ left?: number;
23
+ };
24
+ /** The minimum distance between an `Arrow` and the toast's corners, in pixels. @default 5 */
25
+ arrowPadding?: number;
26
+ /** Keeps the toast in view while its anchor scrolls out of view. */
27
+ sticky?: boolean;
28
+ /** The CSS `position` of the positioner. @default "absolute" */
29
+ positionMethod?: "absolute" | "fixed";
30
+ /** Stops following the anchor when it moves (e.g. on scroll). */
31
+ disableAnchorTracking?: boolean;
32
+ };
33
+ /** What a toast is created with. */
34
+ export type ToastOptions<Data extends object = object> = {
35
+ /** Adding a toast with an existing `id` updates it in place and restarts its timer. */
36
+ id?: string;
37
+ title?: ReactNode;
38
+ description?: ReactNode;
39
+ /** Any string. It is set as `data-type` on the toast and its parts, e.g. `"success"` or a form message's type. */
40
+ type?: string;
41
+ /** Milliseconds before the toast closes by itself. `0` keeps it open. Defaults to the provider's `timeout`. */
42
+ timeout?: number;
43
+ /**
44
+ * How screen readers announce it: `"low"` politely, `"high"` urgently.
45
+ * @default "low"
46
+ */
47
+ priority?: "low" | "high";
48
+ /** Your own data, e.g. to pick an icon. */
49
+ data?: Data;
50
+ /** Props of `BaseToast.Action`. It renders only when this has `children`. */
51
+ actionProps?: ComponentPropsWithoutRef<"button">;
52
+ /** Called when the toast starts closing. */
53
+ onClose?: () => void;
54
+ /** Called when the toast is removed, after its exit transition. */
55
+ onRemove?: () => void;
56
+ /** Anchors the toast to an element. Only `anchor` is required. */
57
+ positionerProps?: ToastPositionerOptions;
58
+ };
59
+ /** A toast in the provider's list. `BaseToast.Viewport` passes each one to its children. */
60
+ export type ToastObject<Data extends object = object> = Omit<ToastOptions<Data>, "id"> & {
61
+ id: string;
62
+ };
63
+ /** The fields to change on an existing toast. */
64
+ export type ToastUpdate<Data extends object = object> = Omit<ToastOptions<Data>, "id">;
65
+ /** A string is a shortcut for `{ description }`. */
66
+ export type ToastPromiseOptions<Value, Data extends object = object> = {
67
+ loading: string | ToastUpdate<Data>;
68
+ success: string | ToastUpdate<Data> | ((result: Value) => string | ToastUpdate<Data>);
69
+ error: string | ToastUpdate<Data> | ((error: unknown) => string | ToastUpdate<Data>);
70
+ };
71
+ /** Creates, updates and closes toasts. */
72
+ export type ToastManager<Data extends object = object> = {
73
+ /** Shows a toast and returns its `id`. */
74
+ add: (options: ToastOptions<Data>) => string;
75
+ /** Closes the toast with this `id`, or every toast without one. */
76
+ close: (id?: string) => void;
77
+ /** Changes an existing toast. */
78
+ update: (id: string, updates: ToastUpdate<Data> | ((toast: ToastObject<Data>) => ToastUpdate<Data>)) => void;
79
+ /** Shows a loading toast that turns into a success or error toast when the promise settles. Returns the promise. */
80
+ promise: <Value>(promise: Promise<Value>, options: ToastPromiseOptions<Value, Data>) => Promise<Value>;
81
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ToastManager, ToastObject } from "./toastTypes.js";
2
+ export type UseToastReturn<Data extends object = object> = ToastManager<Data> & {
3
+ /** The toasts that are shown (or still transitioning out), newest first. */
4
+ toasts: ToastObject<Data>[];
5
+ };
6
+ /** Shows, updates and closes toasts. Call it inside `ToastProvider`. */
7
+ export default function useToast<Data extends object = object>(): UseToastReturn<Data>;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { Toast } from "@base-ui/react/toast";
3
+ // src/components/feedback/useToast.ts
4
+ /** Shows, updates and closes toasts. Call it inside `ToastProvider`. */
5
+ function useToast() {
6
+ return Toast.useToastManager();
7
+ }
8
+ export { useToast as default };
@@ -65,5 +65,5 @@ export declare function splitFilterProps<Props extends MenuRootSharedProps>({ fi
65
65
  event: Event | undefined;
66
66
  }) => void) | undefined;
67
67
  } | null;
68
- rootProps: Omit<Props, "filter" | "locale" | "autoHighlight" | "filterable" | "query" | "defaultQuery" | "onQueryChange">;
68
+ rootProps: Omit<Props, "filter" | "locale" | "filterable" | "autoHighlight" | "query" | "defaultQuery" | "onQueryChange">;
69
69
  };
@@ -0,0 +1,92 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { TooltipTriggerState } from "./BaseTooltipTrigger.js";
3
+ import "../../utils/index.js";
4
+ import { TooltipAlign, TooltipCollisionAvoidance, TooltipOffsetFunction, TooltipPopupState, TooltipPositionerState, TooltipSide } from "./BaseTooltipPopup.js";
5
+ import { TooltipArrowState } from "./BaseTooltipArrow.js";
6
+ import { TooltipViewportState } from "./BaseTooltipViewport.js";
7
+ import { TooltipHandle } from "./createTooltipHandle.js";
8
+ import { ReactNode, RefObject } from "react";
9
+ /** Imperative actions, through `actionsRef`. */
10
+ export type TooltipActions = {
11
+ /** Closes the tooltip. */
12
+ close: () => void;
13
+ };
14
+ type BaseTooltipProps<Payload = unknown> = {
15
+ open?: boolean;
16
+ defaultOpen?: boolean;
17
+ /** Called with the new state and the DOM event that changed it (none when it was changed from code). */
18
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
19
+ /** Called after the open or close transition ends. */
20
+ onOpenChangeComplete?: (open: boolean) => void;
21
+ /** Closes the tooltip when the pointer leaves the trigger, even onto the popup. @default false */
22
+ disableHoverablePopup?: boolean;
23
+ /** Makes the popup follow the pointer along this axis. @default "none" */
24
+ trackCursorAxis?: "none" | "x" | "y" | "both";
25
+ /** Stops every trigger from opening the tooltip. */
26
+ disabled?: boolean;
27
+ /** Imperative actions, e.g. `actionsRef.current?.close()`. */
28
+ actionsRef?: RefObject<TooltipActions | null>;
29
+ /** Connects triggers placed outside the tooltip, and opens it from code. Create one with `createTooltipHandle()`. */
30
+ handle?: TooltipHandle<Payload>;
31
+ /** The `id` of the trigger the tooltip belongs to, for a controlled tooltip with several triggers. */
32
+ triggerId?: string | null;
33
+ /** The `id` of the trigger an initially open tooltip belongs to. */
34
+ defaultTriggerId?: string | null;
35
+ /** The tooltip's parts, or a function that gets the payload of the trigger that opened it. */
36
+ children?: ReactNode | ((context: {
37
+ payload: Payload | undefined;
38
+ }) => ReactNode);
39
+ };
40
+ declare const _default: (<Payload>({ handle, onOpenChange, ...otherProps }: BaseTooltipProps<Payload>) => import("react").JSX.Element) & {
41
+ Provider: (props: {
42
+ children?: ReactNode;
43
+ delay?: number;
44
+ closeDelay?: number;
45
+ timeout?: number;
46
+ }) => import("react").JSX.Element;
47
+ Trigger: <Payload>({ handle, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "disabled"> & {
48
+ render?: RenderProp<"button", TooltipTriggerState>;
49
+ handle?: TooltipHandle<Payload> | undefined;
50
+ payload?: Payload | undefined;
51
+ delay?: number;
52
+ closeDelay?: number;
53
+ closeOnClick?: boolean;
54
+ disabled?: boolean;
55
+ }) => import("react").JSX.Element;
56
+ Popup: ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
57
+ render?: RenderProp<"div", TooltipPopupState>;
58
+ side?: TooltipSide;
59
+ align?: TooltipAlign;
60
+ sideOffset?: number | TooltipOffsetFunction;
61
+ alignOffset?: number | TooltipOffsetFunction;
62
+ collisionPadding?: number | {
63
+ top?: number;
64
+ right?: number;
65
+ bottom?: number;
66
+ left?: number;
67
+ };
68
+ collisionBoundary?: "clipping-ancestors" | Element | Element[] | {
69
+ x: number;
70
+ y: number;
71
+ width: number;
72
+ height: number;
73
+ };
74
+ collisionAvoidance?: TooltipCollisionAvoidance;
75
+ anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
76
+ disableAnchorTracking?: boolean;
77
+ arrowPadding?: number;
78
+ sticky?: boolean;
79
+ positionMethod?: "absolute" | "fixed";
80
+ positionerClassName?: string;
81
+ renderPositioner?: RenderProp<"div", TooltipPositionerState>;
82
+ container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
83
+ keepMounted?: boolean;
84
+ }) => import("react").JSX.Element;
85
+ Arrow: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
86
+ render?: RenderProp<"div", TooltipArrowState>;
87
+ }) => import("react").JSX.Element;
88
+ Viewport: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
89
+ render?: RenderProp<"div", TooltipViewportState>;
90
+ }) => import("react").JSX.Element;
91
+ };
92
+ export { _default as default };
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { Tooltip } from "@base-ui/react/tooltip";
3
+ import TooltipProvider from "../providers/TooltipProvider.js";
4
+ import BaseTooltipArrow from "./BaseTooltipArrow.js";
5
+ import BaseTooltipPopup from "./BaseTooltipPopup.js";
6
+ import BaseTooltipTrigger from "./BaseTooltipTrigger.js";
7
+ import BaseTooltipViewport from "./BaseTooltipViewport.js";
8
+ import { toBaseUIHandle } from "./createTooltipHandle.js";
9
+ import { jsx } from "react/jsx-runtime";
10
+ // src/components/overlay/BaseTooltip.tsx
11
+ /** Groups the parts of a tooltip and holds its open state. Renders no element. */
12
+ const BaseTooltip = ({ handle, onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Tooltip.Root, {
13
+ ...otherProps,
14
+ handle: handle && toBaseUIHandle(handle),
15
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
16
+ });
17
+ var BaseTooltip_default = Object.assign(BaseTooltip, {
18
+ Provider: TooltipProvider,
19
+ Trigger: BaseTooltipTrigger,
20
+ Popup: BaseTooltipPopup,
21
+ Arrow: BaseTooltipArrow,
22
+ Viewport: BaseTooltipViewport
23
+ });
24
+ export { BaseTooltip_default as default };
@@ -0,0 +1,20 @@
1
+ import { TooltipAlign, TooltipInstant, TooltipSide } from "./BaseTooltipPopup.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type TooltipArrowState = {
5
+ open: boolean;
6
+ side: TooltipSide;
7
+ align: TooltipAlign;
8
+ /** Whether the arrow can't point at the center of the anchor. */
9
+ uncentered: boolean;
10
+ instant: TooltipInstant;
11
+ };
12
+ type BaseTooltipArrowProps = ComponentProps<"div"> & {
13
+ render?: RenderProp<"div", TooltipArrowState>;
14
+ };
15
+ /**
16
+ * An arrow that points at the trigger. Put it inside `Popup`.
17
+ * Renders a `<div>` with `data-side`, `data-align` and `data-uncentered`. Size and draw it with `className` or `children`.
18
+ */
19
+ declare const BaseTooltipArrow: (props: BaseTooltipArrowProps) => import("react").JSX.Element;
20
+ export { BaseTooltipArrow as default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Tooltip } from "@base-ui/react/tooltip";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/overlay/BaseTooltipArrow.tsx
5
+ /**
6
+ * An arrow that points at the trigger. Put it inside `Popup`.
7
+ * Renders a `<div>` with `data-side`, `data-align` and `data-uncentered`. Size and draw it with `className` or `children`.
8
+ */
9
+ const BaseTooltipArrow = (props) => /* @__PURE__ */ jsx(Tooltip.Arrow, { ...props });
10
+ export { BaseTooltipArrow as default };
@@ -0,0 +1,106 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps, RefObject } from "react";
3
+ export type TooltipSide = "top" | "bottom" | "left" | "right" | "inline-start" | "inline-end";
4
+ export type TooltipAlign = "start" | "center" | "end";
5
+ /**
6
+ * Why the transition is skipped, also set as `data-instant`: `"delay"` when another tooltip was just open,
7
+ * `"focus"` when opened by keyboard focus, `"dismiss"` when closed by Escape or a click. Empty otherwise.
8
+ */
9
+ export type TooltipInstant = "delay" | "focus" | "dismiss" | undefined;
10
+ export type TooltipPopupState = {
11
+ open: boolean;
12
+ side: TooltipSide;
13
+ align: TooltipAlign;
14
+ instant: TooltipInstant;
15
+ };
16
+ export type TooltipPositionerState = {
17
+ open: boolean;
18
+ side: TooltipSide;
19
+ align: TooltipAlign;
20
+ /** Whether the anchor is scrolled out of view. */
21
+ anchorHidden: boolean;
22
+ instant: string | undefined;
23
+ };
24
+ /** Computes an offset from the popup's placement and the sizes of the anchor and the popup. */
25
+ export type TooltipOffsetFunction = (data: {
26
+ side: TooltipSide;
27
+ align: TooltipAlign;
28
+ anchor: {
29
+ width: number;
30
+ height: number;
31
+ };
32
+ positioner: {
33
+ width: number;
34
+ height: number;
35
+ };
36
+ }) => number;
37
+ /** How the popup avoids the edges of `collisionBoundary`. */
38
+ export type TooltipCollisionAvoidance = {
39
+ side?: "flip" | "none";
40
+ align?: "flip" | "shift" | "none";
41
+ fallbackAxisSide?: "start" | "end" | "none";
42
+ } | {
43
+ side?: "shift" | "none";
44
+ align?: "shift" | "none";
45
+ fallbackAxisSide?: "start" | "end" | "none";
46
+ };
47
+ type Rect = {
48
+ x: number;
49
+ y: number;
50
+ width: number;
51
+ height: number;
52
+ };
53
+ type BaseTooltipPopupProps = ComponentProps<"div"> & {
54
+ render?: RenderProp<"div", TooltipPopupState>;
55
+ /** The side of the anchor the popup is placed on. It flips when there's no room. @default "top" */
56
+ side?: TooltipSide;
57
+ /** How the popup is aligned to that side. @default "center" */
58
+ align?: TooltipAlign;
59
+ /** The gap between the anchor and the popup, in pixels, or a function of the placement and sizes. */
60
+ sideOffset?: number | TooltipOffsetFunction;
61
+ /** Moves the popup along the anchor's side, in pixels, or a function of the placement and sizes. */
62
+ alignOffset?: number | TooltipOffsetFunction;
63
+ /**
64
+ * The space kept between the popup and the edges of the viewport, in pixels.
65
+ * @default 5
66
+ */
67
+ collisionPadding?: number | {
68
+ top?: number;
69
+ right?: number;
70
+ bottom?: number;
71
+ left?: number;
72
+ };
73
+ /** The area the popup stays inside. @default "clipping-ancestors" */
74
+ collisionBoundary?: "clipping-ancestors" | Element | Element[] | Rect;
75
+ collisionAvoidance?: TooltipCollisionAvoidance;
76
+ /** The element the popup is placed against. Defaults to the trigger. */
77
+ anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
78
+ /** Stops following the anchor when it moves (e.g. on scroll). */
79
+ disableAnchorTracking?: boolean;
80
+ /**
81
+ * The minimum distance between an `Arrow` and the popup's corners, in pixels.
82
+ * @default 5
83
+ */
84
+ arrowPadding?: number;
85
+ /** Keeps the popup in view while its anchor scrolls out of view. */
86
+ sticky?: boolean;
87
+ /**
88
+ * The CSS `position` of the positioner. Use `"fixed"` when the anchor is inside a fixed container.
89
+ * @default "absolute"
90
+ */
91
+ positionMethod?: "absolute" | "fixed";
92
+ /** Classes for the positioner, the `<div>` around the popup that places it. */
93
+ positionerClassName?: string;
94
+ /** Style or replace the positioner. A `className` on the element wins over the kit's conflicting classes. */
95
+ renderPositioner?: RenderProp<"div", TooltipPositionerState>;
96
+ /** Where the popup is portaled to. Defaults to `<body>`. */
97
+ container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
98
+ /** Keeps the popup in the DOM while the tooltip is closed. */
99
+ keepMounted?: boolean;
100
+ };
101
+ /**
102
+ * The tooltip's popup, with its portal and positioner.
103
+ * Renders a `<div>` with `data-side`, `data-align`, `data-open` / `data-closed`, `data-instant` and transition attributes.
104
+ */
105
+ declare const BaseTooltipPopup: ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, className, ...otherProps }: BaseTooltipPopupProps) => import("react").JSX.Element;
106
+ export { BaseTooltipPopup as default };
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { Tooltip } from "@base-ui/react/tooltip";
3
+ import { cn } from "cn";
4
+ import { splitClassName } from "../../utils/split-class-name.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/overlay/BaseTooltipPopup.tsx
7
+ /**
8
+ * The tooltip's popup, with its portal and positioner.
9
+ * Renders a `<div>` with `data-side`, `data-align`, `data-open` / `data-closed`, `data-instant` and transition attributes.
10
+ */
11
+ const BaseTooltipPopup = ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, className, ...otherProps }) => {
12
+ const positionerElement = splitClassName(renderPositioner);
13
+ return /* @__PURE__ */ jsx(Tooltip.Portal, {
14
+ container,
15
+ keepMounted,
16
+ children: /* @__PURE__ */ jsx(Tooltip.Positioner, {
17
+ side,
18
+ align,
19
+ sideOffset,
20
+ alignOffset,
21
+ collisionPadding,
22
+ collisionBoundary,
23
+ collisionAvoidance,
24
+ anchor,
25
+ disableAnchorTracking,
26
+ arrowPadding,
27
+ sticky,
28
+ positionMethod,
29
+ render: positionerElement.render,
30
+ className: cn("z-50", positionerClassName, positionerElement.className),
31
+ children: /* @__PURE__ */ jsx(Tooltip.Popup, {
32
+ ...otherProps,
33
+ className: cn("origin-(--transform-origin)", "transition-[scale,opacity]", "duration-100", "ease-out", "data-ending-style:scale-95", "data-ending-style:opacity-0", "data-starting-style:scale-95", "data-starting-style:opacity-0", "data-instant:transition-none", className)
34
+ })
35
+ })
36
+ });
37
+ };
38
+ export { BaseTooltipPopup as default };
@@ -0,0 +1,31 @@
1
+ import { TooltipHandle } from "./createTooltipHandle.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type TooltipTriggerState = {
5
+ /** Whether the tooltip is open and was opened by this trigger. */
6
+ open: boolean;
7
+ };
8
+ type BaseTooltipTriggerProps<Payload = unknown> = Omit<ComponentProps<"button">, "disabled"> & {
9
+ render?: RenderProp<"button", TooltipTriggerState>;
10
+ /** Connects a trigger placed outside its `BaseTooltip`. Create one with `createTooltipHandle()`. */
11
+ handle?: TooltipHandle<Payload>;
12
+ /** Passed to the tooltip's function children when this trigger opens it. */
13
+ payload?: Payload;
14
+ /** The wait before opening on hover, in milliseconds. Overrides `TooltipProvider`'s. @default 600 */
15
+ delay?: number;
16
+ /** The wait before closing, in milliseconds. Overrides `TooltipProvider`'s. @default 0 */
17
+ closeDelay?: number;
18
+ /** Closes the tooltip when the trigger is clicked. @default true */
19
+ closeOnClick?: boolean;
20
+ /**
21
+ * Stops this trigger from opening the tooltip. The element itself stays enabled (it gets `data-trigger-disabled`).
22
+ * To disable the button as well, pass `disabled` to the `render` element.
23
+ */
24
+ disabled?: boolean;
25
+ };
26
+ /**
27
+ * The element the tooltip belongs to. Hovering or focusing it opens the tooltip.
28
+ * Renders a `<button>`, with `data-popup-open` while its tooltip is open.
29
+ */
30
+ declare const BaseTooltipTrigger: <Payload>({ handle, ...otherProps }: BaseTooltipTriggerProps<Payload>) => import("react").JSX.Element;
31
+ export { BaseTooltipTrigger as default };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { Tooltip } from "@base-ui/react/tooltip";
3
+ import { toBaseUIHandle } from "./createTooltipHandle.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/overlay/BaseTooltipTrigger.tsx
6
+ /**
7
+ * The element the tooltip belongs to. Hovering or focusing it opens the tooltip.
8
+ * Renders a `<button>`, with `data-popup-open` while its tooltip is open.
9
+ */
10
+ const BaseTooltipTrigger = ({ handle, ...otherProps }) => /* @__PURE__ */ jsx(Tooltip.Trigger, {
11
+ ...otherProps,
12
+ handle: handle && toBaseUIHandle(handle)
13
+ });
14
+ export { BaseTooltipTrigger as default };
@@ -0,0 +1,20 @@
1
+ import { TooltipInstant } from "./BaseTooltipPopup.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type TooltipViewportState = {
5
+ /** The direction the new trigger is in, relative to the previous one (e.g. `"right"`). */
6
+ activationDirection: string | undefined;
7
+ /** Whether the content is changing from one trigger's to another's. */
8
+ transitioning: boolean;
9
+ instant: TooltipInstant;
10
+ };
11
+ type BaseTooltipViewportProps = ComponentProps<"div"> & {
12
+ render?: RenderProp<"div", TooltipViewportState>;
13
+ };
14
+ /**
15
+ * Animates the popup's content when one tooltip is opened by several triggers and its content depends
16
+ * on the trigger. Wrap the content in it, inside the popup. Renders a `<div>`, with
17
+ * `data-activation-direction` and `data-transitioning`.
18
+ */
19
+ declare const BaseTooltipViewport: (props: BaseTooltipViewportProps) => import("react").JSX.Element;
20
+ export { BaseTooltipViewport as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Tooltip } from "@base-ui/react/tooltip";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/overlay/BaseTooltipViewport.tsx
5
+ /**
6
+ * Animates the popup's content when one tooltip is opened by several triggers and its content depends
7
+ * on the trigger. Wrap the content in it, inside the popup. Renders a `<div>`, with
8
+ * `data-activation-direction` and `data-transitioning`.
9
+ */
10
+ const BaseTooltipViewport = (props) => /* @__PURE__ */ jsx(Tooltip.Viewport, { ...props });
11
+ export { BaseTooltipViewport as default };
@@ -0,0 +1,30 @@
1
+ /** Carries a handle's payload type. Type-only: it doesn't exist at runtime. */
2
+ declare const payloadType: unique symbol;
3
+ /**
4
+ * Opens and closes a tooltip from anywhere: from triggers outside the tooltip and from code.
5
+ * Create one with `createTooltipHandle()` and pass it to `BaseTooltip` and its triggers.
6
+ *
7
+ * A tooltip is placed against a trigger, so it can only be opened through one: there is no `openWithPayload`.
8
+ * Calls are ignored while no `BaseTooltip` with this handle is mounted.
9
+ * Call the methods from event handlers or effects, never during render.
10
+ */
11
+ export type TooltipHandle<Payload = unknown> = {
12
+ /** Opens the tooltip on the trigger with this `id`. The trigger must use the same handle. */
13
+ open: (triggerId: string) => void;
14
+ close: () => void;
15
+ /** Whether the tooltip is open. `false` while no `BaseTooltip` with this handle is mounted. */
16
+ readonly isOpen: boolean;
17
+ /** Types the payload of triggers and of `BaseTooltip`'s function children. Never set. */
18
+ readonly [payloadType]?: Payload;
19
+ };
20
+ /**
21
+ * Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
22
+ * Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
23
+ */
24
+ export declare function toBaseUIHandle<Payload>(handle: TooltipHandle<Payload>): object | undefined;
25
+ /**
26
+ * Creates a handle to open a tooltip from triggers outside it, or from code.
27
+ * Pass the payload type to type the payload of triggers and of `BaseTooltip`'s function children.
28
+ */
29
+ export default function createTooltipHandle<Payload = unknown>(): TooltipHandle<Payload>;
30
+ export {};
@@ -0,0 +1,27 @@
1
+ import { Tooltip } from "@base-ui/react/tooltip";
2
+ // src/components/overlay/createTooltipHandle.ts
3
+ const baseUIHandles = /* @__PURE__ */ new WeakMap();
4
+ /**
5
+ * Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
6
+ * Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
7
+ */
8
+ function toBaseUIHandle(handle) {
9
+ return baseUIHandles.get(handle);
10
+ }
11
+ /**
12
+ * Creates a handle to open a tooltip from triggers outside it, or from code.
13
+ * Pass the payload type to type the payload of triggers and of `BaseTooltip`'s function children.
14
+ */
15
+ function createTooltipHandle() {
16
+ const baseUIHandle = Tooltip.createHandle();
17
+ const handle = {
18
+ open: (triggerId) => baseUIHandle.open(triggerId),
19
+ close: () => baseUIHandle.close(),
20
+ get isOpen() {
21
+ return baseUIHandle.isOpen;
22
+ }
23
+ };
24
+ baseUIHandles.set(handle, baseUIHandle);
25
+ return handle;
26
+ }
27
+ export { createTooltipHandle as default, toBaseUIHandle };
@@ -0,0 +1,7 @@
1
+ import _default, { TooltipActions } from "./BaseTooltip.js";
2
+ import createTooltipHandle, { TooltipHandle } from "./createTooltipHandle.js";
3
+ import { TooltipTriggerState } from "./BaseTooltipTrigger.js";
4
+ import { TooltipAlign, TooltipCollisionAvoidance, TooltipInstant, TooltipOffsetFunction, TooltipPopupState, TooltipPositionerState, TooltipSide } from "./BaseTooltipPopup.js";
5
+ import { TooltipArrowState } from "./BaseTooltipArrow.js";
6
+ import { TooltipViewportState } from "./BaseTooltipViewport.js";
7
+ export { _default as BaseTooltip, type TooltipActions, type TooltipAlign, type TooltipArrowState, type TooltipCollisionAvoidance, type TooltipHandle, type TooltipInstant, type TooltipOffsetFunction, type TooltipPopupState, type TooltipPositionerState, type TooltipSide, type TooltipTriggerState, type TooltipViewportState, createTooltipHandle };