@omer-x/tailwind-ui-kit 1.0.0-alpha.22 → 1.0.0-alpha.23

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
@@ -352,7 +352,7 @@ Every part takes `className` and `render`. `Trigger` and `Close` also take `nati
352
352
  | `container` | `HTMLElement \| ShadowRoot \| RefObject \| null` | `<body>` | Where the popup is portaled to |
353
353
  | `keepMounted` | `boolean` | `false` | Keeps the popup in the DOM while closed |
354
354
  | `backdrop` | `boolean` | `true` | Set to `false` for no backdrop. Nested dialogs never render one |
355
- | `renderBackdrop` | `RenderProp<"div", DialogBackdropState>` | | Style or replace the backdrop: a fixed full-screen black overlay (lighter in light mode, darker in dark mode) with a fade transition |
355
+ | `renderBackdrop` | `RenderProp<"div", DialogBackdropState>` | | Style or replace the backdrop: a fixed full-screen black overlay (`opacity-20`, `dark:opacity-70`) with a fade transition. A `className` on the element wins over the kit's conflicting classes (`<div className="opacity-50" />`). A function gets the kit's classes in `props.className` |
356
356
  | `render` | `RenderProp<"div", DialogPopupState>` | | The state is `{ open, nested, nestedDialogOpen }` |
357
357
 
358
358
  Data attributes: the popup and backdrop have `data-open` / `data-closed` and `data-starting-style` / `data-ending-style` during transitions. The popup also has `data-nested` (inside another dialog) and `data-nested-dialog-open` (a dialog inside it is open).
@@ -1,5 +1,5 @@
1
- import { RenderProp } from "../../utils/render.js";
2
1
  import { ComponentProps, RefObject } from "react";
2
+ import { RenderProp } from "../../utils/render.js";
3
3
  export type DialogPopupState = {
4
4
  open: boolean;
5
5
  /** Whether the dialog is inside another dialog. */
@@ -33,6 +33,7 @@ type BaseDialogPopupProps = ComponentProps<"div"> & {
33
33
  keepMounted?: boolean;
34
34
  /** Set to `false` to render no backdrop. Nested dialogs render none either way. */
35
35
  backdrop?: boolean;
36
+ /** A `className` on the element replaces the kit's conflicting classes (e.g. `opacity-50`). */
36
37
  renderBackdrop?: RenderProp<"div", DialogBackdropState>;
37
38
  };
38
39
  /** The dialog's window, with its portal and backdrop. Renders a `<div>`. */
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { Dialog } from "@base-ui/react/dialog";
3
3
  import { cn } from "cn";
4
+ import { cloneElement, isValidElement } from "react";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
6
  // src/components/dialog/BaseDialogPopup.tsx
6
7
  const sizes = {
@@ -9,16 +10,33 @@ const sizes = {
9
10
  md: "w-96",
10
11
  lg: "w-lg"
11
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
+ }
12
27
  /** The dialog's window, with its portal and backdrop. Renders a `<div>`. */
13
- const BaseDialogPopup = ({ size = "md", container, keepMounted, backdrop = true, renderBackdrop, className, ...otherProps }) => /* @__PURE__ */ jsxs(Dialog.Portal, {
14
- container,
15
- keepMounted,
16
- children: [backdrop && /* @__PURE__ */ jsx(Dialog.Backdrop, {
17
- render: renderBackdrop,
18
- 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")
19
- }), /* @__PURE__ */ jsx(Dialog.Popup, {
20
- ...otherProps,
21
- 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)
22
- })]
23
- });
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
+ };
24
42
  export { BaseDialogPopup as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omer-x/tailwind-ui-kit",
3
- "version": "1.0.0-alpha.22",
3
+ "version": "1.0.0-alpha.23",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
6
  "tailwind",