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

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 CHANGED
@@ -1131,6 +1131,127 @@ import { BaseMenubar } from "@omer-x/tailwind-ui-kit/menu";
1131
1131
  | `loopFocus` | `boolean` | `true` | Arrow keys wrap from the last trigger to the first |
1132
1132
  | `render` | `RenderProp<"div", MenubarState>` | | The state is `{ orientation, modal, hasSubmenuOpen }` |
1133
1133
 
1134
+ ### `@omer-x/tailwind-ui-kit/overlay`
1135
+
1136
+ #### `BaseTooltip`
1137
+
1138
+ A Base UI [`Tooltip`](https://base-ui.com/react/components/tooltip): a popup that shows a hint when its trigger is hovered or focused. `Popup` brings its portal and positioner, so a tooltip needs no more than this:
1139
+
1140
+ ```tsx
1141
+ import { BaseTooltip } from "@omer-x/tailwind-ui-kit/overlay";
1142
+
1143
+ <BaseTooltip>
1144
+ <BaseTooltip.Trigger render={<Button />}>Save</BaseTooltip.Trigger>
1145
+ <BaseTooltip.Popup className="rounded bg-neutral-900 px-2 py-1 text-xs text-white" sideOffset={8}>
1146
+ Saves your changes
1147
+ <BaseTooltip.Arrow className="size-2 rotate-45 bg-neutral-900 data-[side=top]:-bottom-1 data-[side=bottom]:-top-1" />
1148
+ </BaseTooltip.Popup>
1149
+ </BaseTooltip>
1150
+ ```
1151
+
1152
+ The parts use dot notation, so build tooltips in a `"use client"` file. A tooltip is only a visual hint: it isn't announced to screen readers, so keep the trigger's accessible name (text or `aria-label`) meaningful without it.
1153
+
1154
+ | Part | Renders | Description |
1155
+ |------|---------|-------------|
1156
+ | `BaseTooltip` | nothing | Groups the parts and holds the open state |
1157
+ | `BaseTooltip.Trigger` | `<button>` | Opens the tooltip on hover (after `delay`) or keyboard focus. `data-popup-open` while its tooltip is open, `data-trigger-disabled` when `disabled` |
1158
+ | `BaseTooltip.Popup` | `<div>` | The tooltip, portaled and placed against the trigger, with scale and fade transitions (skipped while `data-instant`) |
1159
+ | `BaseTooltip.Arrow` | `<div>` | An arrow pointing at the trigger, inside `Popup`. `data-side`, `data-align`, `data-uncentered`. Draw it yourself |
1160
+ | `BaseTooltip.Viewport` | `<div>` | Animates the content when one tooltip is opened by several triggers and its content depends on the trigger. `data-activation-direction`, `data-transitioning` |
1161
+ | `BaseTooltip.Provider` | nothing | The same component as [`TooltipProvider`](#tooltipprovider) |
1162
+
1163
+ `BaseTooltip` props:
1164
+
1165
+ | Prop | Type | Default | Description |
1166
+ |------|------|---------|-------------|
1167
+ | `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial open state |
1168
+ | `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
1169
+ | `onOpenChangeComplete` | `(open) => void` | | Called after the open or close transition ends |
1170
+ | `disableHoverablePopup` | `boolean` | `false` | Closes the tooltip as soon as the pointer leaves the trigger, even onto the popup |
1171
+ | `trackCursorAxis` | `"none" \| "x" \| "y" \| "both"` | `"none"` | Makes the popup follow the pointer along this axis |
1172
+ | `disabled` | `boolean` | `false` | No trigger opens the tooltip |
1173
+ | `actionsRef` | `RefObject<TooltipActions>` | | `actionsRef.current?.close()` |
1174
+ | `handle` | `TooltipHandle<Payload>` | | Connects triggers outside the tooltip and opens it from code (see below) |
1175
+ | `triggerId` / `defaultTriggerId` | `string \| null` | | The trigger a controlled / initially open tooltip belongs to |
1176
+ | `children` | `ReactNode \| ({ payload }) => ReactNode` | | The parts, or a function that gets the payload of the trigger that opened the tooltip |
1177
+
1178
+ `BaseTooltip.Trigger` props:
1179
+
1180
+ | Prop | Type | Default | Description |
1181
+ |------|------|---------|-------------|
1182
+ | `delay` | `number` | `600` | The wait before opening on hover, in ms. Overrides `TooltipProvider`'s |
1183
+ | `closeDelay` | `number` | `0` | The wait before closing, in ms. Overrides `TooltipProvider`'s |
1184
+ | `closeOnClick` | `boolean` | `true` | Closes the tooltip when the trigger is clicked |
1185
+ | `disabled` | `boolean` | `false` | Stops this trigger from opening the tooltip. The element stays enabled: to disable the button too, pass `disabled` to the `render` element |
1186
+ | `handle` / `payload` | `TooltipHandle<Payload>` / `Payload` | | Connects a trigger outside its `BaseTooltip`, and the payload it passes (see below) |
1187
+ | `render` | `RenderProp<"button", TooltipTriggerState>` | | The state is `{ open }`. Use it to render your themed button, or any other element |
1188
+
1189
+ `BaseTooltip.Popup` props:
1190
+
1191
+ | Prop | Type | Default | Description |
1192
+ |------|------|---------|-------------|
1193
+ | `side` / `align` | `TooltipSide` / `TooltipAlign` | `"top"` / `"center"` | Where the popup sits against the trigger (`"top"`, `"bottom"`, `"left"`, `"right"`, `"inline-start"`, `"inline-end"` / `"start"`, `"center"`, `"end"`). It flips when there's no room |
1194
+ | `sideOffset` / `alignOffset` | `number \| TooltipOffsetFunction` | | Offsets from the anchor, in pixels, or a function of the placement and sizes |
1195
+ | `collisionPadding` | `number \| { top, right, bottom, left }` | `5` | Space kept from the viewport edges |
1196
+ | `collisionBoundary` / `collisionAvoidance` | | `"clipping-ancestors"` | The area the popup stays inside, and how it avoids its edges (flip or shift) |
1197
+ | `anchor` | `Element \| RefObject \| () => Element \| null` | the trigger | The element the popup is placed against |
1198
+ | `disableAnchorTracking` | `boolean` | `false` | Stops following the anchor when it moves |
1199
+ | `arrowPadding` | `number` | `5` | Minimum distance between an `Arrow` and the popup's corners |
1200
+ | `sticky` | `boolean` | `false` | Stays in view while the anchor scrolls away |
1201
+ | `positionMethod` | `"absolute" \| "fixed"` | `"absolute"` | Use `"fixed"` when the anchor is inside a fixed container |
1202
+ | `positionerClassName` / `renderPositioner` | `string` / `RenderProp<"div", TooltipPositionerState>` | | Style or replace the positioner, the `<div>` around the popup that places it (`z-50`) |
1203
+ | `container` | `HTMLElement \| ShadowRoot \| RefObject \| null` | `<body>` | Where the popup is portaled to |
1204
+ | `keepMounted` | `boolean` | `false` | Keeps the popup in the DOM while closed |
1205
+ | `render` | `RenderProp<"div", TooltipPopupState>` | | The state is `{ open, side, align, instant }` |
1206
+
1207
+ Data attributes: the popup has `data-open` / `data-closed`, `data-side`, `data-align` and `data-starting-style` / `data-ending-style` during transitions. `data-instant` is set when the transition should be skipped: `"delay"` (another tooltip was just open), `"focus"` (opened by keyboard focus) or `"dismiss"` (closed by Escape or a click). The popup's own transition is turned off then (`data-instant:transition-none`).
1208
+
1209
+ #### `createTooltipHandle`
1210
+
1211
+ Opens one tooltip from triggers anywhere on the page, or from code. Each trigger can pass a `payload`, which the tooltip's function children receive:
1212
+
1213
+ ```tsx
1214
+ import { BaseTooltip, createTooltipHandle } from "@omer-x/tailwind-ui-kit/overlay";
1215
+
1216
+ const shortcutTooltip = createTooltipHandle<{ id: string, keys: string }>();
1217
+
1218
+ // triggers anywhere on the page
1219
+ <BaseTooltip.Trigger id={`shortcut-${s.id}`} handle={shortcutTooltip} payload={s} render={<Button />}>{s.label}</BaseTooltip.Trigger>
1220
+
1221
+ // one tooltip on the page
1222
+ <BaseTooltip handle={shortcutTooltip}>
1223
+ {({ payload }) => payload && (
1224
+ <BaseTooltip.Popup>{payload.keys}</BaseTooltip.Popup>
1225
+ )}
1226
+ </BaseTooltip>
1227
+
1228
+ // from code
1229
+ shortcutTooltip.open("shortcut-copy");
1230
+ ```
1231
+
1232
+ A `TooltipHandle<Payload>` has `open(triggerId)`, `close()` and `isOpen`. Like `MenuHandle`, it has no `openWithPayload`: a tooltip is placed against its trigger, so `open` needs the `id` of a trigger with the same handle.
1233
+
1234
+ - Calls are **ignored while the tooltip isn't mounted**. Keep the `BaseTooltip` with the handle rendered.
1235
+ - Call them **from event handlers or effects, never during render**.
1236
+
1237
+ ### `@omer-x/tailwind-ui-kit/providers`
1238
+
1239
+ #### `TooltipProvider`
1240
+
1241
+ Shares the hover delay between the tooltips inside it: once one tooltip is shown, the next one opens instantly. Place it once around your app (or a toolbar) in a `"use client"` file. It renders no element and is also available as `BaseTooltip.Provider`.
1242
+
1243
+ ```tsx
1244
+ import { TooltipProvider } from "@omer-x/tailwind-ui-kit/providers";
1245
+
1246
+ <TooltipProvider delay={300}>{children}</TooltipProvider>
1247
+ ```
1248
+
1249
+ | Prop | Type | Default | Description |
1250
+ |------|------|---------|-------------|
1251
+ | `delay` | `number` | `600` | The wait before opening a tooltip on hover, in ms. A trigger's own `delay` wins |
1252
+ | `closeDelay` | `number` | `0` | The wait before closing a tooltip, in ms. A trigger's own `closeDelay` wins |
1253
+ | `timeout` | `number` | `400` | A tooltip opened within this time after another one closed opens without a delay, in ms |
1254
+
1134
1255
  ### `@omer-x/tailwind-ui-kit/disclosure`
1135
1256
 
1136
1257
  #### `BaseAccordion`
@@ -108,7 +108,7 @@ declare const _default: (<Item>({ onValueChange, onOpenChange, onItemHighlighted
108
108
  InputGroup: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
109
109
  render?: RenderProp<"div", AutocompleteInputState>;
110
110
  }) => import("react").JSX.Element;
111
- Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value" | "size"> & {
111
+ Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "size" | "value" | "defaultValue"> & {
112
112
  size?: InputSize;
113
113
  render?: RenderProp<"input", AutocompleteInputState>;
114
114
  }) => import("react").JSX.Element;
@@ -154,7 +154,7 @@ declare const _default: (<Payload>(props: BaseMenuProps<Payload>) => import("rea
154
154
  closeDelay?: number;
155
155
  nativeButton?: boolean;
156
156
  }) => import("react").JSX.Element;
157
- Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value"> & {
157
+ Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue"> & {
158
158
  render?: RenderProp<"input", MenuInputState>;
159
159
  }) => import("react").JSX.Element;
160
160
  Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
@@ -169,7 +169,7 @@ declare const _default: (({ className, ...otherProps }: BaseMenubarProps) => imp
169
169
  closeDelay?: number;
170
170
  nativeButton?: boolean;
171
171
  }) => import("react").JSX.Element;
172
- Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value"> & {
172
+ Input: (props: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue"> & {
173
173
  render?: RenderProp<"input", MenuInputState>;
174
174
  }) => import("react").JSX.Element;
175
175
  Clear: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
@@ -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 };
@@ -0,0 +1,3 @@
1
+ import BaseTooltip_default from "./BaseTooltip.js";
2
+ import createTooltipHandle from "./createTooltipHandle.js";
3
+ export { BaseTooltip_default as BaseTooltip, createTooltipHandle };
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from "react";
2
+ type TooltipProviderProps = {
3
+ children?: ReactNode;
4
+ /** The wait before opening a tooltip on hover, in milliseconds. A trigger's own `delay` wins. */
5
+ delay?: number;
6
+ /** The wait before closing a tooltip, in milliseconds. A trigger's own `closeDelay` wins. */
7
+ closeDelay?: number;
8
+ /**
9
+ * When a tooltip closes, the next one opened within this time opens without a delay, in milliseconds.
10
+ * @default 400
11
+ */
12
+ timeout?: number;
13
+ };
14
+ /**
15
+ * Shares the open delay between the tooltips inside it: once one is shown, the ones next to it open instantly.
16
+ * Usually placed once around the app. Renders no element.
17
+ */
18
+ declare const TooltipProvider: (props: TooltipProviderProps) => import("react").JSX.Element;
19
+ export { TooltipProvider 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/providers/TooltipProvider.tsx
5
+ /**
6
+ * Shares the open delay between the tooltips inside it: once one is shown, the ones next to it open instantly.
7
+ * Usually placed once around the app. Renders no element.
8
+ */
9
+ const TooltipProvider = (props) => /* @__PURE__ */ jsx(Tooltip.Provider, { ...props });
10
+ export { TooltipProvider as default };
@@ -0,0 +1,2 @@
1
+ import TooltipProvider from "./TooltipProvider.js";
2
+ export { TooltipProvider };
@@ -0,0 +1 @@
1
+ export { default as TooltipProvider } from "./TooltipProvider.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omer-x/tailwind-ui-kit",
3
- "version": "1.0.0-alpha.41",
3
+ "version": "1.0.0-alpha.42",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
6
  "tailwind",
@@ -62,6 +62,14 @@
62
62
  "types": "./dist/components/form/index.d.ts",
63
63
  "import": "./dist/components/form/index.js"
64
64
  },
65
+ "./overlay": {
66
+ "types": "./dist/components/overlay/index.d.ts",
67
+ "import": "./dist/components/overlay/index.js"
68
+ },
69
+ "./providers": {
70
+ "types": "./dist/components/providers/index.d.ts",
71
+ "import": "./dist/components/providers/index.js"
72
+ },
65
73
  "./table": {
66
74
  "types": "./dist/components/table/index.d.ts",
67
75
  "import": "./dist/components/table/index.js"