@omer-x/tailwind-ui-kit 1.0.0-alpha.29 → 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.
package/README.md CHANGED
@@ -405,6 +405,61 @@ A `DialogHandle<Payload>` has `open(triggerId?)`, `openWithPayload(payload)`, `c
405
405
  - Calls are **ignored while the dialog isn't mounted**. Keep the `BaseDialog` with the handle rendered.
406
406
  - Call them **from event handlers or effects, never during render**.
407
407
 
408
+ #### `BaseAlertDialog`
409
+
410
+ A Base UI [`Alert Dialog`](https://base-ui.com/react/components/alert-dialog): a modal dialog the user has to respond to. It works like `BaseDialog`, with these differences:
411
+
412
+ - The popup has `role="alertdialog"`.
413
+ - It is always modal, and outside presses don't close it. Escape and `Close` buttons still do. There are no `modal` or `disablePointerDismissal` props.
414
+ - `Popup`, `Title`, `Description` and `Close` are `BaseDialog`'s parts, so they look the same and take the same props (`size`, `initialFocus`, `renderBackdrop`, …).
415
+
416
+ ```tsx
417
+ import { BaseAlertDialog } from "@omer-x/tailwind-ui-kit/dialog";
418
+
419
+ <BaseAlertDialog>
420
+ <BaseAlertDialog.Trigger render={<Button />}>Discard draft</BaseAlertDialog.Trigger>
421
+ <BaseAlertDialog.Popup size="sm" className="rounded-lg bg-white p-6 shadow-lg">
422
+ <BaseAlertDialog.Title>Discard draft?</BaseAlertDialog.Title>
423
+ <BaseAlertDialog.Description>You can't undo this action.</BaseAlertDialog.Description>
424
+ <BaseAlertDialog.Close render={<Button />}>Cancel</BaseAlertDialog.Close>
425
+ <BaseAlertDialog.Close render={<Button />} onClick={discard}>Discard</BaseAlertDialog.Close>
426
+ </BaseAlertDialog.Popup>
427
+ </BaseAlertDialog>
428
+ ```
429
+
430
+ | Part | Renders | Description |
431
+ |------|---------|-------------|
432
+ | `BaseAlertDialog` | nothing | Groups the parts and holds the open state |
433
+ | `BaseAlertDialog.Trigger` | `<button>` | Opens the alert dialog. `data-popup-open` while its alert dialog is open |
434
+ | `BaseAlertDialog.Popup` | `<div>` | Same as `BaseDialog.Popup` |
435
+ | `BaseAlertDialog.Title` | `<h2>` | Same as `BaseDialog.Title` |
436
+ | `BaseAlertDialog.Description` | `<p>` | Same as `BaseDialog.Description` |
437
+ | `BaseAlertDialog.Close` | `<button>` | Same as `BaseDialog.Close` |
438
+
439
+ `BaseAlertDialog` takes `BaseDialog`'s props except `modal` and `disablePointerDismissal`: `open`, `defaultOpen`, `onOpenChange`, `onOpenChangeComplete`, `handle` (an `AlertDialogHandle<Payload>`), `triggerId`, `defaultTriggerId` and `children` (parts, or a function of `{ payload }`).
440
+
441
+ Put it inside a `BaseDialog.Popup` to confirm something from a dialog: it stacks on top like a nested dialog.
442
+
443
+ #### `createAlertDialogHandle`
444
+
445
+ `createDialogHandle` for alert dialogs. It returns an `AlertDialogHandle<Payload>` with the same methods (`open`, `openWithPayload`, `close`, `isOpen`) and the same rules. Pass it to `BaseAlertDialog` and `BaseAlertDialog.Trigger`:
446
+
447
+ ```tsx
448
+ import { BaseAlertDialog, createAlertDialogHandle } from "@omer-x/tailwind-ui-kit/dialog";
449
+
450
+ const removeAlert = createAlertDialogHandle<{ id: string, name: string }>();
451
+
452
+ <BaseAlertDialog.Trigger handle={removeAlert} payload={member} render={<Button />}>Remove</BaseAlertDialog.Trigger>
453
+
454
+ <BaseAlertDialog handle={removeAlert}>
455
+ {({ payload }) => payload && (
456
+ <BaseAlertDialog.Popup size="sm">
457
+ <BaseAlertDialog.Title>Remove {payload.name}?</BaseAlertDialog.Title>
458
+ </BaseAlertDialog.Popup>
459
+ )}
460
+ </BaseAlertDialog>
461
+ ```
462
+
408
463
  ### `@omer-x/tailwind-ui-kit/disclosure`
409
464
 
410
465
  #### `BaseAccordion`
@@ -473,6 +528,55 @@ Every part takes `className` and `render`.
473
528
 
474
529
  Data attributes: the item, heading and panel have `data-open` and `data-index`. The trigger has `data-panel-open`. Disabled parts have `data-disabled`. The panel has `data-starting-style` / `data-ending-style` during its transition.
475
530
 
531
+ ### `@omer-x/tailwind-ui-kit/display`
532
+
533
+ #### `BaseAvatar`
534
+
535
+ A Base UI [`Avatar`](https://base-ui.com/react/components/avatar): a profile picture with a fallback (initials or an icon) shown while it is missing, loading or broken.
536
+
537
+ ```tsx
538
+ import { BaseAvatar } from "@omer-x/tailwind-ui-kit/display";
539
+
540
+ <BaseAvatar size="sm" className="bg-neutral-200 font-medium">
541
+ <BaseAvatar.Image src={user.photoUrl} alt={user.name} />
542
+ <BaseAvatar.Fallback>{initials}</BaseAvatar.Fallback>
543
+ </BaseAvatar>
544
+ ```
545
+
546
+ The parts are reached with dot notation (`BaseAvatar.Image`), which only works in client components. Build avatars in a `"use client"` file, e.g. your app's themed wrapper.
547
+
548
+ | Part | Renders | Description |
549
+ |------|---------|-------------|
550
+ | `BaseAvatar` | `<span>` | A round, centered, `overflow-hidden` box of the given size. Make it square with `className="rounded-md"` |
551
+ | `BaseAvatar.Image` | `<img>` | The picture, covering the box (`size-full object-cover`). Rendered only once it has loaded |
552
+ | `BaseAvatar.Fallback` | `<span>` | Fills the box and centers its content. Rendered until the image has loaded |
553
+
554
+ Every part takes `className` and `render`.
555
+
556
+ `BaseAvatar` props:
557
+
558
+ | Prop | Type | Default | Description |
559
+ |------|------|---------|-------------|
560
+ | `size` | `"lg" \| "md" \| "sm" \| "xs"` | `"md"` | `size-12 text-lg` / `size-10 text-base` / `size-8 text-sm` / `size-6 text-xs` |
561
+ | `render` | `RenderProp<"span", AvatarState>` | | The state is `{ imageLoadingStatus }`: `"idle"`, `"loading"`, `"loaded"` or `"error"` |
562
+
563
+ `BaseAvatar.Image` props:
564
+
565
+ | Prop | Type | Default | Description |
566
+ |------|------|---------|-------------|
567
+ | `onLoadingStatusChange` | `(status) => void` | | Called when the image starts loading, loads or fails |
568
+ | `keepMounted` | `boolean` | `false` | Keeps the `<img>` in the DOM and loads it in place instead of preloading it. Use it for `loading="lazy"` or an optimized image component (`render={<NextImage … />}`). Hide it until it loads with `data-loading:invisible data-error:hidden` |
569
+ | `render` | `RenderProp<"img", AvatarImageState>` | | The avatar's state plus `transitionStatus` |
570
+
571
+ `BaseAvatar.Fallback` props:
572
+
573
+ | Prop | Type | Default | Description |
574
+ |------|------|---------|-------------|
575
+ | `delay` | `number` | `0` | Milliseconds to wait before showing, so a fast image doesn't flash it |
576
+ | `render` | `RenderProp<"span", AvatarState>` | | |
577
+
578
+ Data attributes: the image has `data-starting-style` / `data-ending-style` while it appears and disappears, so it can fade in (`transition-opacity data-starting-style:opacity-0`). With `keepMounted`, it has `data-loading` while loading and `data-error` when it failed.
579
+
476
580
  ### `@omer-x/tailwind-ui-kit/layout`
477
581
 
478
582
  #### `Container`
@@ -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,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 };
@@ -14,6 +14,15 @@ export type DialogHandle<Payload = unknown> = {
14
14
  /** Whether the dialog is open. `false` while no `BaseDialog` with this handle is mounted. */
15
15
  readonly isOpen: boolean;
16
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>;
17
26
  /**
18
27
  * Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
19
28
  * Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
@@ -23,4 +32,5 @@ export declare function toBaseUIHandle(handle: DialogHandle<never>): object | un
23
32
  * Creates a handle to open a dialog from triggers outside it, or from code.
24
33
  * Pass the payload type to type the payload of triggers and `openWithPayload`.
25
34
  */
26
- export default function createDialogHandle<Payload = unknown>(): DialogHandle<Payload>;
35
+ export default function createDialogHandle<Payload = unknown>(): DialogHandle<Payload>;
36
+ export {};
@@ -1,6 +1,19 @@
1
1
  import { Dialog } from "@base-ui/react/dialog";
2
2
  // src/components/dialog/createDialogHandle.ts
3
3
  const baseUIHandles = /* @__PURE__ */ new WeakMap();
4
+ /** Wraps a Base UI dialog or alert dialog handle in a kit handle. Internal: not exported to apps. */
5
+ function toKitHandle(baseUIHandle) {
6
+ const handle = {
7
+ open: (triggerId = null) => baseUIHandle.open(triggerId),
8
+ openWithPayload: (payload) => baseUIHandle.openWithPayload(payload),
9
+ close: () => baseUIHandle.close(),
10
+ get isOpen() {
11
+ return baseUIHandle.isOpen;
12
+ }
13
+ };
14
+ baseUIHandles.set(handle, baseUIHandle);
15
+ return handle;
16
+ }
4
17
  /**
5
18
  * Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
6
19
  * Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
@@ -13,16 +26,6 @@ function toBaseUIHandle(handle) {
13
26
  * Pass the payload type to type the payload of triggers and `openWithPayload`.
14
27
  */
15
28
  function createDialogHandle() {
16
- const baseUIHandle = Dialog.createHandle();
17
- const handle = {
18
- open: (triggerId = null) => baseUIHandle.open(triggerId),
19
- openWithPayload: (payload) => baseUIHandle.openWithPayload(payload),
20
- close: () => baseUIHandle.close(),
21
- get isOpen() {
22
- return baseUIHandle.isOpen;
23
- }
24
- };
25
- baseUIHandles.set(handle, baseUIHandle);
26
- return handle;
29
+ return toKitHandle(Dialog.createHandle());
27
30
  }
28
- export { createDialogHandle as default, toBaseUIHandle };
31
+ export { createDialogHandle as default, toBaseUIHandle, toKitHandle };
@@ -1,6 +1,8 @@
1
- import _default from "./BaseDialog.js";
1
+ import _default from "./BaseAlertDialog.js";
2
+ import _default$1 from "./BaseDialog.js";
3
+ import createAlertDialogHandle, { AlertDialogHandle } from "./createAlertDialogHandle.js";
2
4
  import createDialogHandle, { DialogHandle } from "./createDialogHandle.js";
3
5
  import { DialogBackdropState, DialogFocusTarget, DialogInteractionType, DialogPopupState } from "./BaseDialogPopup.js";
4
6
  import { DialogCloseState } from "./BaseDialogClose.js";
5
7
  import { DialogTriggerState } from "./BaseDialogTrigger.js";
6
- export { _default as BaseDialog, type DialogBackdropState, type DialogCloseState, type DialogFocusTarget, type DialogHandle, type DialogInteractionType, type DialogPopupState, type DialogTriggerState, createDialogHandle };
8
+ export { type AlertDialogHandle, _default as BaseAlertDialog, _default$1 as BaseDialog, type DialogBackdropState, type DialogCloseState, type DialogFocusTarget, type DialogHandle, type DialogInteractionType, type DialogPopupState, type DialogTriggerState, createAlertDialogHandle, createDialogHandle };
@@ -1,3 +1,5 @@
1
+ import BaseAlertDialog_default from "./BaseAlertDialog.js";
1
2
  import BaseDialog_default from "./BaseDialog.js";
3
+ import createAlertDialogHandle from "./createAlertDialogHandle.js";
2
4
  import createDialogHandle from "./createDialogHandle.js";
3
- export { BaseDialog_default as BaseDialog, createDialogHandle };
5
+ export { BaseAlertDialog_default as BaseAlertDialog, BaseDialog_default as BaseDialog, createAlertDialogHandle, createDialogHandle };
@@ -0,0 +1,24 @@
1
+ import { AvatarImageState } from "./BaseAvatarImage.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type AvatarImageLoadingStatus = "idle" | "loading" | "loaded" | "error";
5
+ export type AvatarState = {
6
+ /** Whether the image is loading, shown, or failed (`"idle"` when there is none). */
7
+ imageLoadingStatus: AvatarImageLoadingStatus;
8
+ };
9
+ type BaseAvatarProps = ComponentProps<"span"> & {
10
+ render?: RenderProp<"span", AvatarState>;
11
+ size?: "lg" | "md" | "sm" | "xs";
12
+ };
13
+ declare const _default: (({ size, className, ...otherProps }: BaseAvatarProps) => import("react").JSX.Element) & {
14
+ Image: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLImageElement> & import("react").ImgHTMLAttributes<HTMLImageElement> & {
15
+ render?: RenderProp<"img", AvatarImageState>;
16
+ onLoadingStatusChange?: (status: AvatarImageLoadingStatus) => void;
17
+ keepMounted?: boolean;
18
+ }) => import("react").JSX.Element;
19
+ Fallback: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
20
+ render?: RenderProp<"span", AvatarState>;
21
+ delay?: number;
22
+ }) => import("react").JSX.Element;
23
+ };
24
+ export { _default as default };
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { Avatar } from "@base-ui/react/avatar";
3
+ import { cn } from "cn";
4
+ import BaseAvatarFallback from "./BaseAvatarFallback.js";
5
+ import BaseAvatarImage from "./BaseAvatarImage.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/display/BaseAvatar.tsx
8
+ /**
9
+ * A round box for a profile picture, initials or a fallback icon. Renders a `<span>`.
10
+ * Put a `BaseAvatar.Image` and a `BaseAvatar.Fallback` inside it.
11
+ */
12
+ const BaseAvatar = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(Avatar.Root, {
13
+ ...otherProps,
14
+ className: cn({
15
+ "size-12 text-lg": size === "lg",
16
+ "size-10 text-base": size === "md",
17
+ "size-8 text-sm": size === "sm",
18
+ "size-6 text-xs": size === "xs"
19
+ }, [
20
+ "relative",
21
+ "inline-flex",
22
+ "shrink-0",
23
+ "items-center",
24
+ "justify-center",
25
+ "overflow-hidden",
26
+ "rounded-full",
27
+ "align-middle",
28
+ "select-none"
29
+ ], className)
30
+ });
31
+ var BaseAvatar_default = Object.assign(BaseAvatar, {
32
+ Image: BaseAvatarImage,
33
+ Fallback: BaseAvatarFallback
34
+ });
35
+ export { BaseAvatar_default as default };
@@ -0,0 +1,14 @@
1
+ import { AvatarState } from "./BaseAvatar.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ type BaseAvatarFallbackProps = ComponentProps<"span"> & {
5
+ render?: RenderProp<"span", AvatarState>;
6
+ /** Waits this many milliseconds before showing, so fast images don't flash it. */
7
+ delay?: number;
8
+ };
9
+ /**
10
+ * Shown when the image is missing, still loading or failed, e.g. initials or an icon.
11
+ * Renders a `<span>` that fills the avatar and centers its content.
12
+ */
13
+ declare const BaseAvatarFallback: ({ className, ...otherProps }: BaseAvatarFallbackProps) => import("react").JSX.Element;
14
+ export { BaseAvatarFallback as default };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { Avatar } from "@base-ui/react/avatar";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/display/BaseAvatarFallback.tsx
6
+ /**
7
+ * Shown when the image is missing, still loading or failed, e.g. initials or an icon.
8
+ * Renders a `<span>` that fills the avatar and centers its content.
9
+ */
10
+ const BaseAvatarFallback = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Avatar.Fallback, {
11
+ ...otherProps,
12
+ className: cn("flex", "size-full", "items-center", "justify-center", className)
13
+ });
14
+ export { BaseAvatarFallback as default };
@@ -0,0 +1,23 @@
1
+ import { AvatarImageLoadingStatus, AvatarState } from "./BaseAvatar.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type AvatarImageState = AvatarState & {
5
+ /** `"starting"` while the image appears, `"ending"` while it disappears. */
6
+ transitionStatus: "starting" | "ending" | "idle" | undefined;
7
+ };
8
+ type BaseAvatarImageProps = ComponentProps<"img"> & {
9
+ render?: RenderProp<"img", AvatarImageState>;
10
+ /** Called when the image starts loading, loads or fails. */
11
+ onLoadingStatusChange?: (status: AvatarImageLoadingStatus) => void;
12
+ /**
13
+ * Keeps the `<img>` in the DOM and loads it in place instead of preloading it,
14
+ * for `loading="lazy"` or an optimized image component such as `next/image`.
15
+ */
16
+ keepMounted?: boolean;
17
+ };
18
+ /**
19
+ * The avatar's picture, covering it. Renders an `<img>` once it has loaded,
20
+ * so the fallback shows while it loads or when it fails.
21
+ */
22
+ declare const BaseAvatarImage: ({ className, ...otherProps }: BaseAvatarImageProps) => import("react").JSX.Element;
23
+ export { BaseAvatarImage as default };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { Avatar } from "@base-ui/react/avatar";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/display/BaseAvatarImage.tsx
6
+ /**
7
+ * The avatar's picture, covering it. Renders an `<img>` once it has loaded,
8
+ * so the fallback shows while it loads or when it fails.
9
+ */
10
+ const BaseAvatarImage = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Avatar.Image, {
11
+ ...otherProps,
12
+ className: cn("size-full", "object-cover", className)
13
+ });
14
+ export { BaseAvatarImage as default };
@@ -0,0 +1,3 @@
1
+ import _default, { AvatarImageLoadingStatus, AvatarState } from "./BaseAvatar.js";
2
+ import { AvatarImageState } from "./BaseAvatarImage.js";
3
+ export { type AvatarImageLoadingStatus, type AvatarImageState, type AvatarState, _default as BaseAvatar };
@@ -0,0 +1 @@
1
+ export { default as BaseAvatar } from "./BaseAvatar.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.29",
3
+ "version": "1.0.0-alpha.30",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
6
  "tailwind",
@@ -50,6 +50,10 @@
50
50
  "types": "./dist/components/disclosure/index.d.ts",
51
51
  "import": "./dist/components/disclosure/index.js"
52
52
  },
53
+ "./display": {
54
+ "types": "./dist/components/display/index.d.ts",
55
+ "import": "./dist/components/display/index.js"
56
+ },
53
57
  "./form": {
54
58
  "types": "./dist/components/form/index.d.ts",
55
59
  "import": "./dist/components/form/index.js"