@omer-x/tailwind-ui-kit 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (120) hide show
  1. package/MIGRATION.md +283 -0
  2. package/README.md +761 -0
  3. package/dist/components/button/BaseButton.d.ts +39 -12
  4. package/dist/components/button/BaseButton.js +57 -51
  5. package/dist/components/button/index.d.ts +2 -4
  6. package/dist/components/button/index.js +1 -4
  7. package/dist/components/dialog/BaseAlertDialog.d.ts +49 -0
  8. package/dist/components/dialog/BaseAlertDialog.js +27 -0
  9. package/dist/components/dialog/BaseAlertDialogTrigger.d.ts +16 -0
  10. package/dist/components/dialog/BaseAlertDialogTrigger.js +11 -0
  11. package/dist/components/dialog/BaseDialog.d.ts +58 -0
  12. package/dist/components/dialog/BaseDialog.js +24 -0
  13. package/dist/components/dialog/BaseDialogClose.d.ts +13 -0
  14. package/dist/components/dialog/BaseDialogClose.js +7 -0
  15. package/dist/components/dialog/BaseDialogDescription.d.ts +8 -0
  16. package/dist/components/dialog/BaseDialogDescription.js +7 -0
  17. package/dist/components/dialog/BaseDialogPopup.d.ts +41 -0
  18. package/dist/components/dialog/BaseDialogPopup.js +42 -0
  19. package/dist/components/dialog/BaseDialogTitle.d.ts +8 -0
  20. package/dist/components/dialog/BaseDialogTitle.js +11 -0
  21. package/dist/components/dialog/BaseDialogTrigger.d.ts +20 -0
  22. package/dist/components/dialog/BaseDialogTrigger.js +11 -0
  23. package/dist/components/dialog/createAlertDialogHandle.d.ts +14 -0
  24. package/dist/components/dialog/createAlertDialogHandle.js +11 -0
  25. package/dist/components/dialog/createDialogHandle.d.ts +36 -0
  26. package/dist/components/dialog/createDialogHandle.js +31 -0
  27. package/dist/components/dialog/index.d.ts +8 -5
  28. package/dist/components/dialog/index.js +5 -8
  29. package/dist/components/disclosure/BaseAccordion.d.ts +48 -0
  30. package/dist/components/disclosure/BaseAccordion.js +18 -0
  31. package/dist/components/disclosure/BaseAccordionItem.d.ts +20 -0
  32. package/dist/components/disclosure/BaseAccordionItem.js +10 -0
  33. package/dist/components/disclosure/BaseAccordionPanel.d.ts +20 -0
  34. package/dist/components/disclosure/BaseAccordionPanel.js +15 -0
  35. package/dist/components/disclosure/BaseAccordionTrigger.d.ts +22 -0
  36. package/dist/components/disclosure/BaseAccordionTrigger.js +23 -0
  37. package/dist/components/disclosure/index.d.ts +4 -0
  38. package/dist/components/disclosure/index.js +1 -0
  39. package/dist/components/disclosure/panelTransition.d.ts +7 -0
  40. package/dist/components/disclosure/panelTransition.js +9 -0
  41. package/dist/components/display/BaseAvatar.d.ts +24 -0
  42. package/dist/components/display/BaseAvatar.js +35 -0
  43. package/dist/components/display/BaseAvatarFallback.d.ts +14 -0
  44. package/dist/components/display/BaseAvatarFallback.js +14 -0
  45. package/dist/components/display/BaseAvatarImage.d.ts +23 -0
  46. package/dist/components/display/BaseAvatarImage.js +14 -0
  47. package/dist/components/display/index.d.ts +3 -0
  48. package/dist/components/display/index.js +1 -0
  49. package/dist/components/elements/JustAnchor.d.ts +7 -0
  50. package/dist/components/elements/JustAnchor.js +11 -0
  51. package/dist/components/elements/JustButton.d.ts +7 -0
  52. package/dist/components/elements/JustButton.js +11 -0
  53. package/dist/components/elements/JustDiv.d.ts +7 -0
  54. package/dist/components/elements/JustDiv.js +11 -0
  55. package/dist/components/elements/JustInput.d.ts +7 -0
  56. package/dist/components/elements/JustInput.js +11 -0
  57. package/dist/components/elements/JustSpan.d.ts +7 -0
  58. package/dist/components/elements/JustSpan.js +11 -0
  59. package/dist/components/elements/index.d.ts +6 -0
  60. package/dist/components/elements/index.js +6 -0
  61. package/dist/components/form/BaseForm.d.ts +13 -0
  62. package/dist/components/form/BaseForm.js +78 -0
  63. package/dist/components/form/BaseFormField.d.ts +24 -0
  64. package/dist/components/form/BaseFormField.js +33 -0
  65. package/dist/components/form/BaseInput.d.ts +7 -0
  66. package/dist/components/form/BaseInput.js +22 -0
  67. package/dist/components/form/BaseSwitch.d.ts +35 -0
  68. package/dist/components/form/BaseSwitch.js +21 -0
  69. package/dist/components/form/ClientSideError.d.ts +9 -0
  70. package/dist/components/form/ClientSideError.js +39 -0
  71. package/dist/components/form/FieldRoot.d.ts +8 -0
  72. package/dist/components/form/FieldRoot.js +21 -0
  73. package/dist/components/form/FormContext.d.ts +28 -0
  74. package/dist/components/form/FormContext.js +12 -0
  75. package/dist/components/form/ServerSideError.d.ts +8 -0
  76. package/dist/components/form/ServerSideError.js +15 -0
  77. package/dist/components/form/index.d.ts +7 -0
  78. package/dist/components/form/index.js +6 -0
  79. package/dist/components/form/useFormMessages.d.ts +10 -0
  80. package/dist/components/form/useFormMessages.js +16 -0
  81. package/dist/components/layout/Container.d.ts +4 -10
  82. package/dist/components/layout/Container.js +9 -10
  83. package/dist/components/layout/index.d.ts +2 -3
  84. package/dist/components/layout/index.js +1 -4
  85. package/dist/components/page/Pagination.d.ts +27 -0
  86. package/dist/components/page/Pagination.js +68 -0
  87. package/dist/components/page/index.d.ts +3 -0
  88. package/dist/components/page/index.js +3 -0
  89. package/dist/components/page/usePagination.d.ts +30 -0
  90. package/dist/components/page/usePagination.js +41 -0
  91. package/dist/components/table/TableCell.d.ts +13 -0
  92. package/dist/components/table/TableCell.js +17 -0
  93. package/dist/components/table/Tdx.d.ts +6 -10
  94. package/dist/components/table/Tdx.js +11 -9
  95. package/dist/components/table/index.d.ts +3 -3
  96. package/dist/components/table/index.js +3 -4
  97. package/dist/hooks/index.d.ts +2 -0
  98. package/dist/hooks/index.js +1 -0
  99. package/dist/hooks/useRipples.d.ts +2 -5
  100. package/dist/hooks/useRipples.js +44 -32
  101. package/dist/utils/cn.d.ts +6 -5
  102. package/dist/utils/cn.js +8 -6
  103. package/dist/utils/dirty-form.d.ts +7 -0
  104. package/dist/utils/dirty-form.js +40 -0
  105. package/dist/utils/index.d.ts +3 -2
  106. package/dist/utils/index.js +2 -3
  107. package/dist/utils/render.d.ts +31 -0
  108. package/dist/utils/render.js +24 -0
  109. package/package.json +60 -26
  110. package/typescript-badge.d.ts +4 -0
  111. package/dist/components/button/PulseButton.d.ts +0 -10
  112. package/dist/components/button/PulseButton.js +0 -24
  113. package/dist/components/dialog/AnimatedPopup.d.ts +0 -6
  114. package/dist/components/dialog/AnimatedPopup.js +0 -34
  115. package/dist/components/dialog/DialogBackdrop.d.ts +0 -6
  116. package/dist/components/dialog/DialogBackdrop.js +0 -26
  117. package/dist/components/dialog/DialogTitle.d.ts +0 -6
  118. package/dist/components/dialog/DialogTitle.js +0 -19
  119. package/dist/styles/ripple.module.css +0 -10
  120. package/dist/styles/ripple.module.d.ts +0 -2
@@ -1,12 +1,39 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ComponentProps, ReactNode } from 'react';
3
- import { Button } from '@base-ui/react/button';
4
-
5
- type BaseButtonProps = ComponentProps<typeof Button> & {
6
- size?: "lg" | "md" | "sm" | "xs";
7
- pending?: boolean;
8
- children: ReactNode;
9
- };
10
- declare const BaseButton: ({ size, pending, disabled, focusableWhenDisabled, className, children, ...otherProps }: BaseButtonProps) => react_jsx_runtime.JSX.Element;
11
-
12
- export { BaseButton as default };
1
+ import { ComponentProps, ReactNode } from "react";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ export type ButtonState = {
4
+ disabled: boolean;
5
+ };
6
+ type CommonProps = ComponentProps<"button"> & {
7
+ render?: RenderProp<"button", ButtonState>;
8
+ /**
9
+ * Set to `false` when `render` doesn't render a `<button>` (e.g. a link),
10
+ * so the button gets the attributes and keyboard handling a non-button element needs.
11
+ */
12
+ nativeButton?: boolean;
13
+ /** Keeps a disabled button focusable, so it stays in the tab order. */
14
+ focusableWhenDisabled?: boolean;
15
+ size?: "lg" | "md" | "sm" | "xs";
16
+ /**
17
+ * Shows the spinner, blocks clicks and keeps the button focusable.
18
+ * A submit button is also pending while its form is submitting.
19
+ */
20
+ pending?: boolean;
21
+ /**
22
+ * Shown while pending. Nothing is shown when it's missing; `data-pending` still marks the state.
23
+ */
24
+ spinner?: ReactNode;
25
+ };
26
+ type TextButtonProps = {
27
+ iconOnly?: false;
28
+ };
29
+ type IconOnlyButtonProps = {
30
+ /**
31
+ * A square button whose only content is an icon. It needs an `aria-label`,
32
+ * and the spinner replaces the icon while pending.
33
+ */
34
+ "iconOnly": true;
35
+ "aria-label": string;
36
+ };
37
+ type BaseButtonProps = CommonProps & (TextButtonProps | IconOnlyButtonProps);
38
+ declare const BaseButton: ({ size, pending: pendingProp, spinner, iconOnly, type, disabled, focusableWhenDisabled, onClick, className, children, ...otherProps }: BaseButtonProps) => import("react").JSX.Element;
39
+ export { BaseButton as default };
@@ -1,52 +1,58 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { faSpinner } from "@fortawesome/free-solid-svg-icons/faSpinner";
3
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4
- import {} from "react";
5
- import { cn } from "../../utils/cn.js";
6
- import PulseButton from "./PulseButton.js";
7
- const BaseButton = ({
8
- size = "md",
9
- pending = false,
10
- disabled,
11
- focusableWhenDisabled,
12
- className,
13
- children,
14
- ...otherProps
15
- }) => /* @__PURE__ */ jsxs(
16
- PulseButton,
17
- {
18
- className: (state) => cn({
19
- // Size
20
- "h-12 px-5 text-base leading-7 gap-3": size === "lg",
21
- "h-10 px-4 text-sm leading-6 gap-3": size === "md",
22
- "h-9 px-3 text-sm leading-5 gap-2": size === "sm",
23
- "h-8 px-2.5 text-xs leading-4 gap-2": size === "xs"
24
- }, [
25
- // Base
26
- "relative",
27
- "flex items-center justify-center",
28
- "rounded-md",
29
- "font-medium",
30
- "select-none",
31
- "outline-0",
32
- "transition-colors",
33
- // Focus
34
- "focus-visible:outline-2",
35
- "focus-visible:outline-offset-2",
36
- // Cursor
37
- "cursor-pointer",
38
- "data-disabled:cursor-default"
39
- ], typeof className === "function" ? className(state) : className),
40
- disabled,
41
- focusableWhenDisabled: pending || focusableWhenDisabled,
42
- ...otherProps,
43
- children: [
44
- pending && /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faSpinner, size: "lg", className: "fa-spin-pulse" }),
45
- children
46
- ]
47
- }
48
- );
49
- var BaseButton_default = BaseButton;
50
- export {
51
- BaseButton_default as default
1
+ "use client";
2
+ import { Button } from "@base-ui/react/button";
3
+ import { cn } from "cn";
4
+ import { use } from "react";
5
+ import { useFormStatus } from "react-dom";
6
+ import { useRipples } from "../../hooks/useRipples.js";
7
+ import { FormContext } from "../form/FormContext.js";
8
+ import { jsxs } from "react/jsx-runtime";
9
+ // src/components/button/BaseButton.tsx
10
+ const BaseButton = ({ size = "md", pending: pendingProp = false, spinner, iconOnly = false, type, disabled = false, focusableWhenDisabled = false, onClick, className, children, ...otherProps }) => {
11
+ const { pending: nativeFormPending } = useFormStatus();
12
+ const { pending: baseFormPending } = use(FormContext);
13
+ const pending = pendingProp || type === "submit" && (nativeFormPending || baseFormPending);
14
+ const [triggerRippleEffect, ripples] = useRipples();
15
+ const handleClick = (e) => {
16
+ onClick?.(e);
17
+ if (!e.defaultPrevented) triggerRippleEffect(e);
18
+ };
19
+ return /* @__PURE__ */ jsxs(Button, {
20
+ ...otherProps,
21
+ type,
22
+ disabled: pending || disabled,
23
+ focusableWhenDisabled: pending || focusableWhenDisabled,
24
+ onClick: handleClick,
25
+ "aria-busy": pending || void 0,
26
+ "data-pending": pending ? "" : void 0,
27
+ "data-icon-only": iconOnly ? "" : void 0,
28
+ className: cn({
29
+ "h-12 text-base leading-7 gap-3": size === "lg",
30
+ "h-10 text-sm leading-6 gap-3": size === "md",
31
+ "h-9 text-sm leading-5 gap-2": size === "sm",
32
+ "h-8 text-xs leading-4 gap-2": size === "xs",
33
+ "px-5": size === "lg" && !iconOnly,
34
+ "px-4": size === "md" && !iconOnly,
35
+ "px-3": size === "sm" && !iconOnly,
36
+ "px-2.5": size === "xs" && !iconOnly,
37
+ "aspect-square px-0": iconOnly
38
+ }, [
39
+ "relative",
40
+ "flex items-center justify-center",
41
+ "rounded-md",
42
+ "font-medium",
43
+ "select-none",
44
+ "outline-0",
45
+ "transition-colors",
46
+ "focus-visible:outline-2",
47
+ "focus-visible:outline-offset-2",
48
+ "cursor-pointer",
49
+ "data-disabled:cursor-default"
50
+ ], className),
51
+ children: [
52
+ ripples,
53
+ pending && spinner,
54
+ !(pending && iconOnly && spinner) && children
55
+ ]
56
+ });
52
57
  };
58
+ export { BaseButton as default };
@@ -1,4 +1,2 @@
1
- export { default as BaseButton } from './BaseButton.js';
2
- import 'react/jsx-runtime';
3
- import 'react';
4
- import '@base-ui/react/button';
1
+ import BaseButton, { ButtonState } from "./BaseButton.js";
2
+ export { BaseButton, type ButtonState };
@@ -1,4 +1 @@
1
- import { default as default2 } from "./BaseButton.js";
2
- export {
3
- default2 as BaseButton
4
- };
1
+ export { default as BaseButton } from "./BaseButton.js";
@@ -0,0 +1,49 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { BaseAlertDialogTriggerProps } from "./BaseAlertDialogTrigger.js";
3
+ import { DialogBackdropState, DialogFocusTarget, DialogPopupState } from "./BaseDialogPopup.js";
4
+ import "../../utils/index.js";
5
+ import { DialogCloseState } from "./BaseDialogClose.js";
6
+ import { AlertDialogHandle } from "./createAlertDialogHandle.js";
7
+ import { ReactNode } from "react";
8
+ type BaseAlertDialogProps<Payload = unknown> = {
9
+ open?: boolean;
10
+ defaultOpen?: boolean;
11
+ /** Called with the new state and the DOM event that changed it (none when it was changed from code). */
12
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
13
+ /** Called after the open or close transition ends. */
14
+ onOpenChangeComplete?: (open: boolean) => void;
15
+ /** Connects triggers placed outside the alert dialog, and opens it from code. Create one with `createAlertDialogHandle()`. */
16
+ handle?: AlertDialogHandle<Payload>;
17
+ /** The `id` of the trigger the alert dialog belongs to, for a controlled alert dialog with several triggers. */
18
+ triggerId?: string | null;
19
+ /** The `id` of the trigger an initially open alert dialog belongs to. */
20
+ defaultTriggerId?: string | null;
21
+ /** The alert dialog's parts, or a function that gets the payload of the trigger that opened it. */
22
+ children?: ReactNode | ((context: {
23
+ payload: Payload | undefined;
24
+ }) => ReactNode);
25
+ };
26
+ declare const _default: (<Payload>({ handle, onOpenChange, ...otherProps }: BaseAlertDialogProps<Payload>) => import("react").JSX.Element) & {
27
+ Trigger: <Payload>({ handle, ...otherProps }: BaseAlertDialogTriggerProps<Payload>) => import("react").JSX.Element;
28
+ Popup: ({ size, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
29
+ size?: "lg" | "md" | "sm" | "xs";
30
+ render?: RenderProp<"div", DialogPopupState>;
31
+ initialFocus?: DialogFocusTarget;
32
+ finalFocus?: DialogFocusTarget;
33
+ container?: HTMLElement | ShadowRoot | import("react").RefObject<HTMLElement | ShadowRoot | null> | null;
34
+ keepMounted?: boolean;
35
+ backdrop?: boolean;
36
+ renderBackdrop?: RenderProp<"div", DialogBackdropState>;
37
+ }) => import("react").JSX.Element;
38
+ Title: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLHeadingElement> & import("react").HTMLAttributes<HTMLHeadingElement> & {
39
+ render?: RenderProp<"h2">;
40
+ }) => import("react").JSX.Element;
41
+ Description: (props: import("react").ClassAttributes<HTMLParagraphElement> & import("react").HTMLAttributes<HTMLParagraphElement> & {
42
+ render?: RenderProp<"p">;
43
+ }) => import("react").JSX.Element;
44
+ Close: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
45
+ render?: RenderProp<"button", DialogCloseState>;
46
+ nativeButton?: boolean;
47
+ }) => import("react").JSX.Element;
48
+ };
49
+ export { _default as default };
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { AlertDialog } from "@base-ui/react/alert-dialog";
3
+ import BaseAlertDialogTrigger from "./BaseAlertDialogTrigger.js";
4
+ import BaseDialogClose from "./BaseDialogClose.js";
5
+ import BaseDialogDescription from "./BaseDialogDescription.js";
6
+ import BaseDialogPopup from "./BaseDialogPopup.js";
7
+ import BaseDialogTitle from "./BaseDialogTitle.js";
8
+ import { toBaseUIHandle } from "./createDialogHandle.js";
9
+ import { jsx } from "react/jsx-runtime";
10
+ // src/components/dialog/BaseAlertDialog.tsx
11
+ /**
12
+ * Groups the parts of an alert dialog: a modal dialog that requires a response.
13
+ * Outside presses don't close it. Renders no element.
14
+ */
15
+ const BaseAlertDialog = ({ handle, onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(AlertDialog.Root, {
16
+ ...otherProps,
17
+ handle: handle && toBaseUIHandle(handle),
18
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
19
+ });
20
+ var BaseAlertDialog_default = Object.assign(BaseAlertDialog, {
21
+ Trigger: BaseAlertDialogTrigger,
22
+ Popup: BaseDialogPopup,
23
+ Title: BaseDialogTitle,
24
+ Description: BaseDialogDescription,
25
+ Close: BaseDialogClose
26
+ });
27
+ export { BaseAlertDialog_default as default };
@@ -0,0 +1,16 @@
1
+ import { DialogTriggerState } from "./BaseDialogTrigger.js";
2
+ import { AlertDialogHandle } from "./createAlertDialogHandle.js";
3
+ import { RenderProp } from "../../utils/render.js";
4
+ import { ComponentProps } from "react";
5
+ export type BaseAlertDialogTriggerProps<Payload = unknown> = ComponentProps<"button"> & {
6
+ render?: RenderProp<"button", DialogTriggerState>;
7
+ /** Connects a trigger placed outside its `BaseAlertDialog`. Create one with `createAlertDialogHandle()`. */
8
+ handle?: AlertDialogHandle<Payload>;
9
+ /** Passed to the alert dialog's function children when this trigger opens it. */
10
+ payload?: Payload;
11
+ /** Set to `false` when `render` doesn't render a `<button>`. */
12
+ nativeButton?: boolean;
13
+ };
14
+ /** A button that opens the alert dialog. Renders a `<button>`, with `data-popup-open` while its alert dialog is open. */
15
+ declare const BaseAlertDialogTrigger: <Payload>({ handle, ...otherProps }: BaseAlertDialogTriggerProps<Payload>) => import("react").JSX.Element;
16
+ export { BaseAlertDialogTrigger as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { AlertDialog } from "@base-ui/react/alert-dialog";
3
+ import { toBaseUIHandle } from "./createDialogHandle.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/dialog/BaseAlertDialogTrigger.tsx
6
+ /** A button that opens the alert dialog. Renders a `<button>`, with `data-popup-open` while its alert dialog is open. */
7
+ const BaseAlertDialogTrigger = ({ handle, ...otherProps }) => /* @__PURE__ */ jsx(AlertDialog.Trigger, {
8
+ ...otherProps,
9
+ handle: handle && toBaseUIHandle(handle)
10
+ });
11
+ export { BaseAlertDialogTrigger as default };
@@ -0,0 +1,58 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { BaseDialogTriggerProps } from "./BaseDialogTrigger.js";
3
+ import { DialogBackdropState, DialogFocusTarget, DialogPopupState } from "./BaseDialogPopup.js";
4
+ import "../../utils/index.js";
5
+ import { DialogCloseState } from "./BaseDialogClose.js";
6
+ import { DialogHandle } from "./createDialogHandle.js";
7
+ import { ReactNode } from "react";
8
+ type BaseDialogProps<Payload = unknown> = {
9
+ open?: boolean;
10
+ defaultOpen?: boolean;
11
+ /** Called with the new state and the DOM event that changed it (none when it was changed from code). */
12
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
13
+ /** Called after the open or close transition ends. */
14
+ onOpenChangeComplete?: (open: boolean) => void;
15
+ /**
16
+ * - `true`: focus is trapped, page scroll is locked and the rest of the page ignores the pointer.
17
+ * - `false`: the rest of the page stays usable.
18
+ * - `"trap-focus"`: focus is trapped, but the page scrolls and takes pointer input.
19
+ * @default true
20
+ */
21
+ modal?: boolean | "trap-focus";
22
+ /** Keeps the dialog open on outside presses. */
23
+ disablePointerDismissal?: boolean;
24
+ /** Connects triggers placed outside the dialog, and opens it from code. Create one with `createDialogHandle()`. */
25
+ handle?: DialogHandle<Payload>;
26
+ /** The `id` of the trigger the dialog belongs to, for a controlled dialog with several triggers. */
27
+ triggerId?: string | null;
28
+ /** The `id` of the trigger an initially open dialog belongs to. */
29
+ defaultTriggerId?: string | null;
30
+ /** The dialog's parts, or a function that gets the payload of the trigger that opened it. */
31
+ children?: ReactNode | ((context: {
32
+ payload: Payload | undefined;
33
+ }) => ReactNode);
34
+ };
35
+ declare const _default: (<Payload>({ handle, onOpenChange, ...otherProps }: BaseDialogProps<Payload>) => import("react").JSX.Element) & {
36
+ Trigger: <Payload>({ handle, ...otherProps }: BaseDialogTriggerProps<Payload>) => import("react").JSX.Element;
37
+ Popup: ({ size, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
38
+ size?: "lg" | "md" | "sm" | "xs";
39
+ render?: RenderProp<"div", DialogPopupState>;
40
+ initialFocus?: DialogFocusTarget;
41
+ finalFocus?: DialogFocusTarget;
42
+ container?: HTMLElement | ShadowRoot | import("react").RefObject<HTMLElement | ShadowRoot | null> | null;
43
+ keepMounted?: boolean;
44
+ backdrop?: boolean;
45
+ renderBackdrop?: RenderProp<"div", DialogBackdropState>;
46
+ }) => import("react").JSX.Element;
47
+ Title: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLHeadingElement> & import("react").HTMLAttributes<HTMLHeadingElement> & {
48
+ render?: RenderProp<"h2">;
49
+ }) => import("react").JSX.Element;
50
+ Description: (props: import("react").ClassAttributes<HTMLParagraphElement> & import("react").HTMLAttributes<HTMLParagraphElement> & {
51
+ render?: RenderProp<"p">;
52
+ }) => import("react").JSX.Element;
53
+ Close: (props: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
54
+ render?: RenderProp<"button", DialogCloseState>;
55
+ nativeButton?: boolean;
56
+ }) => import("react").JSX.Element;
57
+ };
58
+ export { _default as default };
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { Dialog } from "@base-ui/react/dialog";
3
+ import BaseDialogClose from "./BaseDialogClose.js";
4
+ import BaseDialogDescription from "./BaseDialogDescription.js";
5
+ import BaseDialogPopup from "./BaseDialogPopup.js";
6
+ import BaseDialogTitle from "./BaseDialogTitle.js";
7
+ import BaseDialogTrigger from "./BaseDialogTrigger.js";
8
+ import { toBaseUIHandle } from "./createDialogHandle.js";
9
+ import { jsx } from "react/jsx-runtime";
10
+ // src/components/dialog/BaseDialog.tsx
11
+ /** Groups the parts of a dialog. Renders no element. */
12
+ const BaseDialog = ({ handle, onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Dialog.Root, {
13
+ ...otherProps,
14
+ handle: handle && toBaseUIHandle(handle),
15
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
16
+ });
17
+ var BaseDialog_default = Object.assign(BaseDialog, {
18
+ Trigger: BaseDialogTrigger,
19
+ Popup: BaseDialogPopup,
20
+ Title: BaseDialogTitle,
21
+ Description: BaseDialogDescription,
22
+ Close: BaseDialogClose
23
+ });
24
+ export { BaseDialog_default as default };
@@ -0,0 +1,13 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ export type DialogCloseState = {
4
+ disabled: boolean;
5
+ };
6
+ type BaseDialogCloseProps = ComponentProps<"button"> & {
7
+ render?: RenderProp<"button", DialogCloseState>;
8
+ /** Set to `false` when `render` doesn't render a `<button>`. */
9
+ nativeButton?: boolean;
10
+ };
11
+ /** A button that closes the dialog. Renders a `<button>`. */
12
+ declare const BaseDialogClose: (props: BaseDialogCloseProps) => import("react").JSX.Element;
13
+ export { BaseDialogClose as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Dialog } from "@base-ui/react/dialog";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/dialog/BaseDialogClose.tsx
5
+ /** A button that closes the dialog. Renders a `<button>`. */
6
+ const BaseDialogClose = (props) => /* @__PURE__ */ jsx(Dialog.Close, { ...props });
7
+ export { BaseDialogClose as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseDialogDescriptionProps = ComponentProps<"p"> & {
4
+ render?: RenderProp<"p">;
5
+ };
6
+ /** A paragraph that describes the dialog to assistive technology. Renders a `<p>`. */
7
+ declare const BaseDialogDescription: (props: BaseDialogDescriptionProps) => import("react").JSX.Element;
8
+ export { BaseDialogDescription as default };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { Dialog } from "@base-ui/react/dialog";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/dialog/BaseDialogDescription.tsx
5
+ /** A paragraph that describes the dialog to assistive technology. Renders a `<p>`. */
6
+ const BaseDialogDescription = (props) => /* @__PURE__ */ jsx(Dialog.Description, { ...props });
7
+ export { BaseDialogDescription as default };
@@ -0,0 +1,41 @@
1
+ import { ComponentProps, RefObject } from "react";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ export type DialogPopupState = {
4
+ open: boolean;
5
+ /** Whether the dialog is inside another dialog. */
6
+ nested: boolean;
7
+ /** Whether a dialog inside this one is open. */
8
+ nestedDialogOpen: boolean;
9
+ };
10
+ export type DialogBackdropState = {
11
+ open: boolean;
12
+ };
13
+ /** How the dialog was opened or closed. Empty when it's unknown (e.g. opened from code). */
14
+ export type DialogInteractionType = "mouse" | "touch" | "pen" | "keyboard" | "";
15
+ /**
16
+ * - `true`: the default (the first tabbable element when opening, the trigger when closing).
17
+ * - `false`: don't move focus.
18
+ * - a ref: focus that element.
19
+ * - a function: return an element, `true` / `null` for the default, or `false` / `undefined` to not move focus.
20
+ */
21
+ export type DialogFocusTarget = boolean | RefObject<HTMLElement | null> | ((interactionType: DialogInteractionType) => boolean | HTMLElement | null | void);
22
+ type BaseDialogPopupProps = ComponentProps<"div"> & {
23
+ /** The popup's width: `xs` 288px, `sm` 320px, `md` 384px, `lg` 512px. Never wider than the viewport. */
24
+ size?: "lg" | "md" | "sm" | "xs";
25
+ render?: RenderProp<"div", DialogPopupState>;
26
+ /** The element focused when the dialog opens. */
27
+ initialFocus?: DialogFocusTarget;
28
+ /** The element focused when the dialog closes. */
29
+ finalFocus?: DialogFocusTarget;
30
+ /** Where the popup is portaled to. Defaults to `<body>`. */
31
+ container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
32
+ /** Keeps the popup in the DOM while the dialog is closed. */
33
+ keepMounted?: boolean;
34
+ /** Set to `false` to render no backdrop. Nested dialogs render none either way. */
35
+ backdrop?: boolean;
36
+ /** A `className` on the element replaces the kit's conflicting classes (e.g. `opacity-50`). */
37
+ renderBackdrop?: RenderProp<"div", DialogBackdropState>;
38
+ };
39
+ /** The dialog's window, with its portal and backdrop. Renders a `<div>`. */
40
+ declare const BaseDialogPopup: ({ size, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: BaseDialogPopupProps) => import("react").JSX.Element;
41
+ export { BaseDialogPopup as default };
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import { Dialog } from "@base-ui/react/dialog";
3
+ import { cn } from "cn";
4
+ import { cloneElement, isValidElement } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/dialog/BaseDialogPopup.tsx
7
+ const sizes = {
8
+ xs: "w-72",
9
+ sm: "w-80",
10
+ md: "w-96",
11
+ lg: "w-lg"
12
+ };
13
+ /**
14
+ * Base UI only joins the `className` of a `render` element with the part's own, so conflicting
15
+ * Tailwind classes would win by their order in the CSS. Moves it into `cn` instead, last so it wins (#14).
16
+ */
17
+ function splitClassName(render) {
18
+ if (!isValidElement(render) || !render.props.className) return {
19
+ render,
20
+ className: void 0
21
+ };
22
+ return {
23
+ render: cloneElement(render, { className: void 0 }),
24
+ className: render.props.className
25
+ };
26
+ }
27
+ /** The dialog's window, with its portal and backdrop. Renders a `<div>`. */
28
+ const BaseDialogPopup = ({ size = "md", container, keepMounted, backdrop = true, renderBackdrop, className, ...otherProps }) => {
29
+ const backdropElement = splitClassName(renderBackdrop);
30
+ return /* @__PURE__ */ jsxs(Dialog.Portal, {
31
+ container,
32
+ keepMounted,
33
+ children: [backdrop && /* @__PURE__ */ jsx(Dialog.Backdrop, {
34
+ render: backdropElement.render,
35
+ className: cn("fixed", "inset-0", "min-h-dvh", "bg-black", "opacity-20", "transition-all", "duration-150", "data-ending-style:opacity-0", "data-starting-style:opacity-0", "dark:opacity-70", "supports-[-webkit-touch-callout:none]:absolute", backdropElement.className)
36
+ }), /* @__PURE__ */ jsx(Dialog.Popup, {
37
+ ...otherProps,
38
+ className: cn("fixed", "top-[calc(50%+1.25rem*var(--nested-dialogs))]", "left-1/2", "-mt-8", sizes[size], "max-w-[calc(100vw-3rem)]", "-translate-x-1/2", "-translate-y-1/2", "scale-[calc(1-0.1*var(--nested-dialogs))]", "transition-all", "duration-150", "data-ending-style:scale-90", "data-ending-style:opacity-0", "data-nested-dialog-open:after:absolute", "data-nested-dialog-open:after:inset-0", "data-nested-dialog-open:after:rounded-[inherit]", "data-nested-dialog-open:after:bg-black/5", "data-starting-style:scale-90", "data-starting-style:opacity-0", className)
39
+ })]
40
+ });
41
+ };
42
+ export { BaseDialogPopup as default };
@@ -0,0 +1,8 @@
1
+ import { RenderProp } from "../../utils/render.js";
2
+ import { ComponentProps } from "react";
3
+ type BaseDialogTitleProps = ComponentProps<"h2"> & {
4
+ render?: RenderProp<"h2">;
5
+ };
6
+ /** The dialog's heading, which also names the dialog. Renders an `<h2>`. */
7
+ declare const BaseDialogTitle: ({ className, ...otherProps }: BaseDialogTitleProps) => import("react").JSX.Element;
8
+ export { BaseDialogTitle as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Dialog } from "@base-ui/react/dialog";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/dialog/BaseDialogTitle.tsx
6
+ /** The dialog's heading, which also names the dialog. Renders an `<h2>`. */
7
+ const BaseDialogTitle = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Dialog.Title, {
8
+ ...otherProps,
9
+ className: cn("-mt-1.5", "mb-1", "text-xl", "font-semibold", className)
10
+ });
11
+ export { BaseDialogTitle as default };
@@ -0,0 +1,20 @@
1
+ import { DialogHandle } from "./createDialogHandle.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type DialogTriggerState = {
5
+ disabled: boolean;
6
+ /** Whether the dialog is open and was opened by this trigger. */
7
+ open: boolean;
8
+ };
9
+ export type BaseDialogTriggerProps<Payload = unknown> = ComponentProps<"button"> & {
10
+ render?: RenderProp<"button", DialogTriggerState>;
11
+ /** Connects a trigger placed outside its `BaseDialog`. Create one with `createDialogHandle()`. */
12
+ handle?: DialogHandle<Payload>;
13
+ /** Passed to the dialog's function children when this trigger opens it. */
14
+ payload?: Payload;
15
+ /** Set to `false` when `render` doesn't render a `<button>`. */
16
+ nativeButton?: boolean;
17
+ };
18
+ /** A button that opens the dialog. Renders a `<button>`, with `data-popup-open` while its dialog is open. */
19
+ declare const BaseDialogTrigger: <Payload>({ handle, ...otherProps }: BaseDialogTriggerProps<Payload>) => import("react").JSX.Element;
20
+ export { BaseDialogTrigger as default };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { Dialog } from "@base-ui/react/dialog";
3
+ import { toBaseUIHandle } from "./createDialogHandle.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/dialog/BaseDialogTrigger.tsx
6
+ /** A button that opens the dialog. Renders a `<button>`, with `data-popup-open` while its dialog is open. */
7
+ const BaseDialogTrigger = ({ handle, ...otherProps }) => /* @__PURE__ */ jsx(Dialog.Trigger, {
8
+ ...otherProps,
9
+ handle: handle && toBaseUIHandle(handle)
10
+ });
11
+ export { BaseDialogTrigger as default };
@@ -0,0 +1,14 @@
1
+ import { DialogHandle } from "./createDialogHandle.js";
2
+ /**
3
+ * Opens and closes an alert dialog from anywhere: from triggers outside the alert dialog and from code.
4
+ * Create one with `createAlertDialogHandle()` and pass it to `BaseAlertDialog` and its triggers.
5
+ *
6
+ * Calls are ignored while no `BaseAlertDialog` with this handle is mounted.
7
+ * Call the methods from event handlers or effects, never during render.
8
+ */
9
+ export type AlertDialogHandle<Payload = unknown> = DialogHandle<Payload>;
10
+ /**
11
+ * Creates a handle to open an alert dialog from triggers outside it, or from code.
12
+ * Pass the payload type to type the payload of triggers and `openWithPayload`.
13
+ */
14
+ export default function createAlertDialogHandle<Payload = unknown>(): AlertDialogHandle<Payload>;
@@ -0,0 +1,11 @@
1
+ import { AlertDialog } from "@base-ui/react/alert-dialog";
2
+ import { toKitHandle } from "./createDialogHandle.js";
3
+ // src/components/dialog/createAlertDialogHandle.ts
4
+ /**
5
+ * Creates a handle to open an alert dialog from triggers outside it, or from code.
6
+ * Pass the payload type to type the payload of triggers and `openWithPayload`.
7
+ */
8
+ function createAlertDialogHandle() {
9
+ return toKitHandle(AlertDialog.createHandle());
10
+ }
11
+ export { createAlertDialogHandle as default };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Opens and closes a dialog from anywhere: from triggers outside the dialog and from code.
3
+ * Create one with `createDialogHandle()` and pass it to `BaseDialog` and its triggers.
4
+ *
5
+ * Calls are ignored while no `BaseDialog` with this handle is mounted.
6
+ * Call the methods from event handlers or effects, never during render.
7
+ */
8
+ export type DialogHandle<Payload = unknown> = {
9
+ /** Opens the dialog. Give a trigger's `id` to open it as if that trigger was pressed. */
10
+ open: (triggerId?: string | null) => void;
11
+ /** Opens the dialog with a payload, which `BaseDialog`'s function children receive. */
12
+ openWithPayload: (payload: Payload) => void;
13
+ close: () => void;
14
+ /** Whether the dialog is open. `false` while no `BaseDialog` with this handle is mounted. */
15
+ readonly isOpen: boolean;
16
+ };
17
+ /** The parts of a Base UI handle the kit uses, typed without naming Base UI. */
18
+ type BaseUIHandleLike<Payload> = {
19
+ open: (triggerId: string | null) => void;
20
+ openWithPayload: (payload: Payload) => void;
21
+ close: () => void;
22
+ readonly isOpen: boolean;
23
+ };
24
+ /** Wraps a Base UI dialog or alert dialog handle in a kit handle. Internal: not exported to apps. */
25
+ export declare function toKitHandle<Payload>(baseUIHandle: BaseUIHandleLike<Payload>): DialogHandle<Payload>;
26
+ /**
27
+ * Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
28
+ * Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
29
+ */
30
+ export declare function toBaseUIHandle(handle: DialogHandle<never>): object | undefined;
31
+ /**
32
+ * Creates a handle to open a dialog from triggers outside it, or from code.
33
+ * Pass the payload type to type the payload of triggers and `openWithPayload`.
34
+ */
35
+ export default function createDialogHandle<Payload = unknown>(): DialogHandle<Payload>;
36
+ export {};