@omer-x/tailwind-ui-kit 1.0.0-alpha.40 → 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.
Files changed (55) hide show
  1. package/README.md +229 -0
  2. package/dist/components/form/BaseAutocomplete.d.ts +1 -1
  3. package/dist/components/form/BaseSelect.d.ts +165 -0
  4. package/dist/components/form/BaseSelect.js +41 -0
  5. package/dist/components/form/BaseSelectGroup.d.ts +8 -0
  6. package/dist/components/form/BaseSelectGroup.js +7 -0
  7. package/dist/components/form/BaseSelectGroupLabel.d.ts +8 -0
  8. package/dist/components/form/BaseSelectGroupLabel.js +7 -0
  9. package/dist/components/form/BaseSelectIcon.d.ts +14 -0
  10. package/dist/components/form/BaseSelectIcon.js +10 -0
  11. package/dist/components/form/BaseSelectItem.d.ts +24 -0
  12. package/dist/components/form/BaseSelectItem.js +14 -0
  13. package/dist/components/form/BaseSelectItemIndicator.d.ts +16 -0
  14. package/dist/components/form/BaseSelectItemIndicator.js +10 -0
  15. package/dist/components/form/BaseSelectItemText.d.ts +8 -0
  16. package/dist/components/form/BaseSelectItemText.js +7 -0
  17. package/dist/components/form/BaseSelectLabel.d.ts +12 -0
  18. package/dist/components/form/BaseSelectLabel.js +10 -0
  19. package/dist/components/form/BaseSelectList.d.ts +8 -0
  20. package/dist/components/form/BaseSelectList.js +11 -0
  21. package/dist/components/form/BaseSelectPopup.d.ts +90 -0
  22. package/dist/components/form/BaseSelectPopup.js +45 -0
  23. package/dist/components/form/BaseSelectScrollDownArrow.d.ts +15 -0
  24. package/dist/components/form/BaseSelectScrollDownArrow.js +17 -0
  25. package/dist/components/form/BaseSelectScrollUpArrow.d.ts +15 -0
  26. package/dist/components/form/BaseSelectScrollUpArrow.js +17 -0
  27. package/dist/components/form/BaseSelectSeparator.d.ts +16 -0
  28. package/dist/components/form/BaseSelectSeparator.js +10 -0
  29. package/dist/components/form/BaseSelectTrigger.d.ts +17 -0
  30. package/dist/components/form/BaseSelectTrigger.js +15 -0
  31. package/dist/components/form/BaseSelectValue.d.ts +21 -0
  32. package/dist/components/form/BaseSelectValue.js +11 -0
  33. package/dist/components/form/index.d.ts +9 -1
  34. package/dist/components/form/index.js +2 -1
  35. package/dist/components/form/selectTypes.d.ts +27 -0
  36. package/dist/components/form/selectTypes.js +1 -0
  37. package/dist/components/overlay/BaseTooltip.d.ts +92 -0
  38. package/dist/components/overlay/BaseTooltip.js +24 -0
  39. package/dist/components/overlay/BaseTooltipArrow.d.ts +20 -0
  40. package/dist/components/overlay/BaseTooltipArrow.js +10 -0
  41. package/dist/components/overlay/BaseTooltipPopup.d.ts +106 -0
  42. package/dist/components/overlay/BaseTooltipPopup.js +38 -0
  43. package/dist/components/overlay/BaseTooltipTrigger.d.ts +31 -0
  44. package/dist/components/overlay/BaseTooltipTrigger.js +14 -0
  45. package/dist/components/overlay/BaseTooltipViewport.d.ts +20 -0
  46. package/dist/components/overlay/BaseTooltipViewport.js +11 -0
  47. package/dist/components/overlay/createTooltipHandle.d.ts +30 -0
  48. package/dist/components/overlay/createTooltipHandle.js +27 -0
  49. package/dist/components/overlay/index.d.ts +7 -0
  50. package/dist/components/overlay/index.js +3 -0
  51. package/dist/components/providers/TooltipProvider.d.ts +19 -0
  52. package/dist/components/providers/TooltipProvider.js +10 -0
  53. package/dist/components/providers/index.d.ts +2 -0
  54. package/dist/components/providers/index.js +1 -0
  55. package/package.json +9 -1
@@ -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.40",
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"