@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.
- package/MIGRATION.md +283 -0
- package/README.md +761 -0
- package/dist/components/button/BaseButton.d.ts +39 -12
- package/dist/components/button/BaseButton.js +57 -51
- package/dist/components/button/index.d.ts +2 -4
- package/dist/components/button/index.js +1 -4
- package/dist/components/dialog/BaseAlertDialog.d.ts +49 -0
- package/dist/components/dialog/BaseAlertDialog.js +27 -0
- package/dist/components/dialog/BaseAlertDialogTrigger.d.ts +16 -0
- package/dist/components/dialog/BaseAlertDialogTrigger.js +11 -0
- package/dist/components/dialog/BaseDialog.d.ts +58 -0
- package/dist/components/dialog/BaseDialog.js +24 -0
- package/dist/components/dialog/BaseDialogClose.d.ts +13 -0
- package/dist/components/dialog/BaseDialogClose.js +7 -0
- package/dist/components/dialog/BaseDialogDescription.d.ts +8 -0
- package/dist/components/dialog/BaseDialogDescription.js +7 -0
- package/dist/components/dialog/BaseDialogPopup.d.ts +41 -0
- package/dist/components/dialog/BaseDialogPopup.js +42 -0
- package/dist/components/dialog/BaseDialogTitle.d.ts +8 -0
- package/dist/components/dialog/BaseDialogTitle.js +11 -0
- package/dist/components/dialog/BaseDialogTrigger.d.ts +20 -0
- package/dist/components/dialog/BaseDialogTrigger.js +11 -0
- package/dist/components/dialog/createAlertDialogHandle.d.ts +14 -0
- package/dist/components/dialog/createAlertDialogHandle.js +11 -0
- package/dist/components/dialog/createDialogHandle.d.ts +36 -0
- package/dist/components/dialog/createDialogHandle.js +31 -0
- package/dist/components/dialog/index.d.ts +8 -5
- package/dist/components/dialog/index.js +5 -8
- package/dist/components/disclosure/BaseAccordion.d.ts +48 -0
- package/dist/components/disclosure/BaseAccordion.js +18 -0
- package/dist/components/disclosure/BaseAccordionItem.d.ts +20 -0
- package/dist/components/disclosure/BaseAccordionItem.js +10 -0
- package/dist/components/disclosure/BaseAccordionPanel.d.ts +20 -0
- package/dist/components/disclosure/BaseAccordionPanel.js +15 -0
- package/dist/components/disclosure/BaseAccordionTrigger.d.ts +22 -0
- package/dist/components/disclosure/BaseAccordionTrigger.js +23 -0
- package/dist/components/disclosure/index.d.ts +4 -0
- package/dist/components/disclosure/index.js +1 -0
- package/dist/components/disclosure/panelTransition.d.ts +7 -0
- package/dist/components/disclosure/panelTransition.js +9 -0
- package/dist/components/display/BaseAvatar.d.ts +24 -0
- package/dist/components/display/BaseAvatar.js +35 -0
- package/dist/components/display/BaseAvatarFallback.d.ts +14 -0
- package/dist/components/display/BaseAvatarFallback.js +14 -0
- package/dist/components/display/BaseAvatarImage.d.ts +23 -0
- package/dist/components/display/BaseAvatarImage.js +14 -0
- package/dist/components/display/index.d.ts +3 -0
- package/dist/components/display/index.js +1 -0
- package/dist/components/elements/JustAnchor.d.ts +7 -0
- package/dist/components/elements/JustAnchor.js +11 -0
- package/dist/components/elements/JustButton.d.ts +7 -0
- package/dist/components/elements/JustButton.js +11 -0
- package/dist/components/elements/JustDiv.d.ts +7 -0
- package/dist/components/elements/JustDiv.js +11 -0
- package/dist/components/elements/JustInput.d.ts +7 -0
- package/dist/components/elements/JustInput.js +11 -0
- package/dist/components/elements/JustSpan.d.ts +7 -0
- package/dist/components/elements/JustSpan.js +11 -0
- package/dist/components/elements/index.d.ts +6 -0
- package/dist/components/elements/index.js +6 -0
- package/dist/components/form/BaseForm.d.ts +13 -0
- package/dist/components/form/BaseForm.js +78 -0
- package/dist/components/form/BaseFormField.d.ts +24 -0
- package/dist/components/form/BaseFormField.js +33 -0
- package/dist/components/form/BaseInput.d.ts +7 -0
- package/dist/components/form/BaseInput.js +22 -0
- package/dist/components/form/BaseSwitch.d.ts +35 -0
- package/dist/components/form/BaseSwitch.js +21 -0
- package/dist/components/form/ClientSideError.d.ts +9 -0
- package/dist/components/form/ClientSideError.js +39 -0
- package/dist/components/form/FieldRoot.d.ts +8 -0
- package/dist/components/form/FieldRoot.js +21 -0
- package/dist/components/form/FormContext.d.ts +28 -0
- package/dist/components/form/FormContext.js +12 -0
- package/dist/components/form/ServerSideError.d.ts +8 -0
- package/dist/components/form/ServerSideError.js +15 -0
- package/dist/components/form/index.d.ts +7 -0
- package/dist/components/form/index.js +6 -0
- package/dist/components/form/useFormMessages.d.ts +10 -0
- package/dist/components/form/useFormMessages.js +16 -0
- package/dist/components/layout/Container.d.ts +4 -10
- package/dist/components/layout/Container.js +9 -10
- package/dist/components/layout/index.d.ts +2 -3
- package/dist/components/layout/index.js +1 -4
- package/dist/components/page/Pagination.d.ts +27 -0
- package/dist/components/page/Pagination.js +68 -0
- package/dist/components/page/index.d.ts +3 -0
- package/dist/components/page/index.js +3 -0
- package/dist/components/page/usePagination.d.ts +30 -0
- package/dist/components/page/usePagination.js +41 -0
- package/dist/components/table/TableCell.d.ts +13 -0
- package/dist/components/table/TableCell.js +17 -0
- package/dist/components/table/Tdx.d.ts +6 -10
- package/dist/components/table/Tdx.js +11 -9
- package/dist/components/table/index.d.ts +3 -3
- package/dist/components/table/index.js +3 -4
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useRipples.d.ts +2 -5
- package/dist/hooks/useRipples.js +44 -32
- package/dist/utils/cn.d.ts +6 -5
- package/dist/utils/cn.js +8 -6
- package/dist/utils/dirty-form.d.ts +7 -0
- package/dist/utils/dirty-form.js +40 -0
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +2 -3
- package/dist/utils/render.d.ts +31 -0
- package/dist/utils/render.js +24 -0
- package/package.json +60 -26
- package/typescript-badge.d.ts +4 -0
- package/dist/components/button/PulseButton.d.ts +0 -10
- package/dist/components/button/PulseButton.js +0 -24
- package/dist/components/dialog/AnimatedPopup.d.ts +0 -6
- package/dist/components/dialog/AnimatedPopup.js +0 -34
- package/dist/components/dialog/DialogBackdrop.d.ts +0 -6
- package/dist/components/dialog/DialogBackdrop.js +0 -26
- package/dist/components/dialog/DialogTitle.d.ts +0 -6
- package/dist/components/dialog/DialogTitle.js +0 -19
- package/dist/styles/ripple.module.css +0 -10
- package/dist/styles/ripple.module.d.ts +0 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
2
|
+
// src/components/dialog/createDialogHandle.ts
|
|
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
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
|
|
19
|
+
* Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
|
|
20
|
+
*/
|
|
21
|
+
function toBaseUIHandle(handle) {
|
|
22
|
+
return baseUIHandles.get(handle);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a handle to open a dialog from triggers outside it, or from code.
|
|
26
|
+
* Pass the payload type to type the payload of triggers and `openWithPayload`.
|
|
27
|
+
*/
|
|
28
|
+
function createDialogHandle() {
|
|
29
|
+
return toKitHandle(Dialog.createHandle());
|
|
30
|
+
}
|
|
31
|
+
export { createDialogHandle as default, toBaseUIHandle, toKitHandle };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import _default from "./BaseAlertDialog.js";
|
|
2
|
+
import _default$1 from "./BaseDialog.js";
|
|
3
|
+
import createAlertDialogHandle, { AlertDialogHandle } from "./createAlertDialogHandle.js";
|
|
4
|
+
import createDialogHandle, { DialogHandle } from "./createDialogHandle.js";
|
|
5
|
+
import { DialogBackdropState, DialogFocusTarget, DialogInteractionType, DialogPopupState } from "./BaseDialogPopup.js";
|
|
6
|
+
import { DialogCloseState } from "./BaseDialogClose.js";
|
|
7
|
+
import { DialogTriggerState } from "./BaseDialogTrigger.js";
|
|
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,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
default3 as DialogBackdrop,
|
|
7
|
-
default4 as DialogTitle
|
|
8
|
-
};
|
|
1
|
+
import BaseAlertDialog_default from "./BaseAlertDialog.js";
|
|
2
|
+
import BaseDialog_default from "./BaseDialog.js";
|
|
3
|
+
import createAlertDialogHandle from "./createAlertDialogHandle.js";
|
|
4
|
+
import createDialogHandle from "./createDialogHandle.js";
|
|
5
|
+
export { BaseAlertDialog_default as BaseAlertDialog, BaseDialog_default as BaseDialog, createAlertDialogHandle, createDialogHandle };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AccordionItemState } from "./BaseAccordionItem.js";
|
|
2
|
+
import { AccordionPanelState } from "./BaseAccordionPanel.js";
|
|
3
|
+
import { RenderProp } from "../../utils/render.js";
|
|
4
|
+
import { ComponentProps } from "react";
|
|
5
|
+
export type AccordionState<Value = unknown> = {
|
|
6
|
+
/** The values of the open items. */
|
|
7
|
+
value: Value[];
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
type BaseAccordionProps<Value = unknown> = Omit<ComponentProps<"div">, "defaultValue"> & {
|
|
11
|
+
render?: RenderProp<"div", AccordionState<Value>>;
|
|
12
|
+
/** The values of the open items (controlled). */
|
|
13
|
+
value?: Value[];
|
|
14
|
+
/** The values of the items open at first. */
|
|
15
|
+
defaultValue?: Value[];
|
|
16
|
+
/** Called with the values of the open items and the DOM event that changed them (none when changed from code). */
|
|
17
|
+
onValueChange?: (value: Value[], event: Event | undefined) => void;
|
|
18
|
+
/** Lets several items be open at once. */
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
/** Ignores user interaction on every item. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** Keeps closed panels in the DOM. */
|
|
23
|
+
keepMounted?: boolean;
|
|
24
|
+
/** Lets the browser's page search find and open closed panels. Overrides `keepMounted`. */
|
|
25
|
+
hiddenUntilFound?: boolean;
|
|
26
|
+
};
|
|
27
|
+
declare const _default: (<Value>({ onValueChange, ...otherProps }: BaseAccordionProps<Value>) => import("react").JSX.Element) & {
|
|
28
|
+
Item: ({ onOpenChange, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
29
|
+
render?: RenderProp<"div", AccordionItemState>;
|
|
30
|
+
value?: unknown;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
33
|
+
}) => import("react").JSX.Element;
|
|
34
|
+
Trigger: ({ icon, iconClassName, headerClassName, renderHeader, className, children, ...otherProps }: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
35
|
+
render?: RenderProp<"button", AccordionItemState>;
|
|
36
|
+
icon?: import("react").ReactNode;
|
|
37
|
+
iconClassName?: string;
|
|
38
|
+
headerClassName?: string;
|
|
39
|
+
renderHeader?: RenderProp<"h3", AccordionItemState>;
|
|
40
|
+
nativeButton?: boolean;
|
|
41
|
+
}) => import("react").JSX.Element;
|
|
42
|
+
Panel: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
43
|
+
render?: RenderProp<"div", AccordionPanelState>;
|
|
44
|
+
keepMounted?: boolean;
|
|
45
|
+
hiddenUntilFound?: boolean;
|
|
46
|
+
}) => import("react").JSX.Element;
|
|
47
|
+
};
|
|
48
|
+
export { _default as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
3
|
+
import BaseAccordionItem from "./BaseAccordionItem.js";
|
|
4
|
+
import BaseAccordionPanel from "./BaseAccordionPanel.js";
|
|
5
|
+
import BaseAccordionTrigger from "./BaseAccordionTrigger.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/components/disclosure/BaseAccordion.tsx
|
|
8
|
+
/** Groups the items of an accordion. Renders a `<div>`. */
|
|
9
|
+
const BaseAccordion = ({ onValueChange, ...otherProps }) => /* @__PURE__ */ jsx(Accordion.Root, {
|
|
10
|
+
...otherProps,
|
|
11
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event))
|
|
12
|
+
});
|
|
13
|
+
var BaseAccordion_default = Object.assign(BaseAccordion, {
|
|
14
|
+
Item: BaseAccordionItem,
|
|
15
|
+
Trigger: BaseAccordionTrigger,
|
|
16
|
+
Panel: BaseAccordionPanel
|
|
17
|
+
});
|
|
18
|
+
export { BaseAccordion_default as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type AccordionItemState = {
|
|
4
|
+
/** Whether the item's panel is open. */
|
|
5
|
+
open: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
/** The item's position in the accordion. */
|
|
8
|
+
index: number;
|
|
9
|
+
};
|
|
10
|
+
type BaseAccordionItemProps = ComponentProps<"div"> & {
|
|
11
|
+
render?: RenderProp<"div", AccordionItemState>;
|
|
12
|
+
/** Identifies the item in the accordion's `value`. Generated when missing. */
|
|
13
|
+
value?: unknown;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Called with the new state and the DOM event that changed it (none when changed from code). */
|
|
16
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
17
|
+
};
|
|
18
|
+
/** Groups a trigger with its panel. Renders a `<div>`, with `data-open` while its panel is open. */
|
|
19
|
+
declare const BaseAccordionItem: ({ onOpenChange, ...otherProps }: BaseAccordionItemProps) => import("react").JSX.Element;
|
|
20
|
+
export { BaseAccordionItem as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/disclosure/BaseAccordionItem.tsx
|
|
5
|
+
/** Groups a trigger with its panel. Renders a `<div>`, with `data-open` while its panel is open. */
|
|
6
|
+
const BaseAccordionItem = ({ onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Accordion.Item, {
|
|
7
|
+
...otherProps,
|
|
8
|
+
onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
|
|
9
|
+
});
|
|
10
|
+
export { BaseAccordionItem as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccordionItemState } from "./BaseAccordionItem.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
export type AccordionPanelState = AccordionItemState & {
|
|
5
|
+
/** `"starting"` while opening, `"ending"` while closing. */
|
|
6
|
+
transitionStatus: "starting" | "ending" | "idle" | undefined;
|
|
7
|
+
};
|
|
8
|
+
type BaseAccordionPanelProps = ComponentProps<"div"> & {
|
|
9
|
+
render?: RenderProp<"div", AccordionPanelState>;
|
|
10
|
+
/** Keeps the panel in the DOM while closed. */
|
|
11
|
+
keepMounted?: boolean;
|
|
12
|
+
/** Lets the browser's page search find and open the panel. Overrides `keepMounted`. */
|
|
13
|
+
hiddenUntilFound?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The item's collapsible content, with a height transition. Renders a `<div>`.
|
|
17
|
+
* Put padding on an element inside it, so the panel can shrink to zero.
|
|
18
|
+
*/
|
|
19
|
+
declare const BaseAccordionPanel: ({ className, ...otherProps }: BaseAccordionPanelProps) => import("react").JSX.Element;
|
|
20
|
+
export { BaseAccordionPanel as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import panelTransition from "./panelTransition.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/disclosure/BaseAccordionPanel.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The item's collapsible content, with a height transition. Renders a `<div>`.
|
|
9
|
+
* Put padding on an element inside it, so the panel can shrink to zero.
|
|
10
|
+
*/
|
|
11
|
+
const BaseAccordionPanel = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Accordion.Panel, {
|
|
12
|
+
...otherProps,
|
|
13
|
+
className: cn("[--disclosure-panel-height:var(--accordion-panel-height)]", panelTransition, className)
|
|
14
|
+
});
|
|
15
|
+
export { BaseAccordionPanel as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AccordionItemState } from "./BaseAccordionItem.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
type BaseAccordionTriggerProps = ComponentProps<"button"> & {
|
|
5
|
+
render?: RenderProp<"button", AccordionItemState>;
|
|
6
|
+
/** Shown after the text, e.g. a chevron. Rotate it with `iconClassName="in-data-panel-open:rotate-180"`. */
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
/** Classes for the `<span>` around the icon. */
|
|
9
|
+
iconClassName?: string;
|
|
10
|
+
/** Classes for the heading around the trigger. */
|
|
11
|
+
headerClassName?: string;
|
|
12
|
+
/** Replaces the heading around the trigger, e.g. `<h2 />` for another level. */
|
|
13
|
+
renderHeader?: RenderProp<"h3", AccordionItemState>;
|
|
14
|
+
/** Set to `false` when `render` doesn't render a `<button>`. */
|
|
15
|
+
nativeButton?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A button that opens and closes its item's panel, inside the heading that labels the panel.
|
|
19
|
+
* Renders an `<h3>` around a `<button>`, with `data-panel-open` while the panel is open.
|
|
20
|
+
*/
|
|
21
|
+
declare const BaseAccordionTrigger: ({ icon, iconClassName, headerClassName, renderHeader, className, children, ...otherProps }: BaseAccordionTriggerProps) => import("react").JSX.Element;
|
|
22
|
+
export { BaseAccordionTrigger as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/disclosure/BaseAccordionTrigger.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A button that opens and closes its item's panel, inside the heading that labels the panel.
|
|
8
|
+
* Renders an `<h3>` around a `<button>`, with `data-panel-open` while the panel is open.
|
|
9
|
+
*/
|
|
10
|
+
const BaseAccordionTrigger = ({ icon, iconClassName, headerClassName, renderHeader, className, children, ...otherProps }) => /* @__PURE__ */ jsx(Accordion.Header, {
|
|
11
|
+
className: headerClassName,
|
|
12
|
+
render: renderHeader,
|
|
13
|
+
children: /* @__PURE__ */ jsxs(Accordion.Trigger, {
|
|
14
|
+
...otherProps,
|
|
15
|
+
className: cn("flex", "w-full", "items-center", "justify-between", "gap-2", "text-left", "focus-visible:outline-2", "focus-visible:outline-offset-2", "data-disabled:cursor-not-allowed", className),
|
|
16
|
+
children: [children, icon && /* @__PURE__ */ jsx("span", {
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
className: cn("flex", "shrink-0", "transition-transform", "duration-150", iconClassName),
|
|
19
|
+
children: icon
|
|
20
|
+
})]
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
export { BaseAccordionTrigger as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import _default, { AccordionState } from "./BaseAccordion.js";
|
|
2
|
+
import { AccordionItemState } from "./BaseAccordionItem.js";
|
|
3
|
+
import { AccordionPanelState } from "./BaseAccordionPanel.js";
|
|
4
|
+
export { type AccordionItemState, type AccordionPanelState, type AccordionState, _default as BaseAccordion };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BaseAccordion } from "./BaseAccordion.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The open/close transition shared by the disclosure panels (Accordion, Collapsible).
|
|
3
|
+
* Each panel maps Base UI's own height variable onto `--disclosure-panel-height`.
|
|
4
|
+
* The panel animates its height, so padding belongs on an element inside it.
|
|
5
|
+
*/
|
|
6
|
+
declare const panelTransition: string;
|
|
7
|
+
export { panelTransition as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
// src/components/disclosure/panelTransition.ts
|
|
3
|
+
/**
|
|
4
|
+
* The open/close transition shared by the disclosure panels (Accordion, Collapsible).
|
|
5
|
+
* Each panel maps Base UI's own height variable onto `--disclosure-panel-height`.
|
|
6
|
+
* The panel animates its height, so padding belongs on an element inside it.
|
|
7
|
+
*/
|
|
8
|
+
const panelTransition = cn("h-(--disclosure-panel-height)", "overflow-hidden", "transition-[height]", "duration-150", "ease-out", "data-ending-style:h-0", "data-starting-style:h-0", "[&[hidden]:not([hidden=until-found])]:hidden");
|
|
9
|
+
export { panelTransition as default };
|
|
@@ -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 @@
|
|
|
1
|
+
export { default as BaseAvatar } from "./BaseAvatar.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type JustAnchorProps = ComponentProps<"a"> & {
|
|
4
|
+
render?: RenderProp<"a">;
|
|
5
|
+
};
|
|
6
|
+
declare const JustAnchor: ({ render, ...props }: JustAnchorProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
export { JustAnchor as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRender } from "../../utils/render.js";
|
|
3
|
+
// src/components/elements/JustAnchor.tsx
|
|
4
|
+
const JustAnchor = ({ render, ...props }) => {
|
|
5
|
+
return useRender({
|
|
6
|
+
defaultTagName: "a",
|
|
7
|
+
render,
|
|
8
|
+
props
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export { JustAnchor as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type JustButtonProps = ComponentProps<"button"> & {
|
|
4
|
+
render?: RenderProp<"button">;
|
|
5
|
+
};
|
|
6
|
+
declare const JustButton: ({ render, ...props }: JustButtonProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
export { JustButton as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRender } from "../../utils/render.js";
|
|
3
|
+
// src/components/elements/JustButton.tsx
|
|
4
|
+
const JustButton = ({ render, ...props }) => {
|
|
5
|
+
return useRender({
|
|
6
|
+
defaultTagName: "button",
|
|
7
|
+
render,
|
|
8
|
+
props
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export { JustButton as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type JustDivProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
declare const JustDiv: ({ render, ...props }: JustDivProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
export { JustDiv as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRender } from "../../utils/render.js";
|
|
3
|
+
// src/components/elements/JustDiv.tsx
|
|
4
|
+
const JustDiv = ({ render, ...props }) => {
|
|
5
|
+
return useRender({
|
|
6
|
+
defaultTagName: "div",
|
|
7
|
+
render,
|
|
8
|
+
props
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export { JustDiv as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type JustInputProps = ComponentProps<"input"> & {
|
|
4
|
+
render?: RenderProp<"input">;
|
|
5
|
+
};
|
|
6
|
+
declare const JustInput: ({ render, ...props }: JustInputProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
export { JustInput as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRender } from "../../utils/render.js";
|
|
3
|
+
// src/components/elements/JustInput.tsx
|
|
4
|
+
const JustInput = ({ render, ...props }) => {
|
|
5
|
+
return useRender({
|
|
6
|
+
defaultTagName: "input",
|
|
7
|
+
render,
|
|
8
|
+
props
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export { JustInput as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type JustSpanProps = ComponentProps<"span"> & {
|
|
4
|
+
render?: RenderProp<"span">;
|
|
5
|
+
};
|
|
6
|
+
declare const JustSpan: ({ render, ...props }: JustSpanProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
export { JustSpan as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRender } from "../../utils/render.js";
|
|
3
|
+
// src/components/elements/JustSpan.tsx
|
|
4
|
+
const JustSpan = ({ render, ...props }) => {
|
|
5
|
+
return useRender({
|
|
6
|
+
defaultTagName: "span",
|
|
7
|
+
render,
|
|
8
|
+
props
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export { JustSpan as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import JustAnchor from "./JustAnchor.js";
|
|
2
|
+
import JustButton from "./JustButton.js";
|
|
3
|
+
import JustDiv from "./JustDiv.js";
|
|
4
|
+
import JustInput from "./JustInput.js";
|
|
5
|
+
import JustSpan from "./JustSpan.js";
|
|
6
|
+
export { JustAnchor, JustButton, JustDiv, JustInput, JustSpan };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import JustAnchor from "./JustAnchor.js";
|
|
2
|
+
import JustButton from "./JustButton.js";
|
|
3
|
+
import JustDiv from "./JustDiv.js";
|
|
4
|
+
import JustInput from "./JustInput.js";
|
|
5
|
+
import JustSpan from "./JustSpan.js";
|
|
6
|
+
export { JustAnchor, JustButton, JustDiv, JustInput, JustSpan };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { MessageFormatter } from "./FormContext.js";
|
|
3
|
+
import { FormAction, FormActionState } from "@omer-x/next-form-actions";
|
|
4
|
+
type BaseFormProps<Data> = Omit<ComponentPropsWithoutRef<"form">, "action"> & {
|
|
5
|
+
action: FormAction<Data>;
|
|
6
|
+
formatMessage?: MessageFormatter;
|
|
7
|
+
defaultValues?: Record<string, unknown>;
|
|
8
|
+
onlyDirty?: boolean;
|
|
9
|
+
resetOnSuccess?: boolean;
|
|
10
|
+
onResult?: (result: FormActionState<Data>) => void;
|
|
11
|
+
};
|
|
12
|
+
declare const BaseForm: <Data>({ action, formatMessage, defaultValues, onlyDirty, resetOnSuccess, onResult, onSubmit, children, ...otherProps }: BaseFormProps<Data>) => import("react").JSX.Element;
|
|
13
|
+
export { BaseForm as default };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Form } from "@base-ui/react/form";
|
|
3
|
+
import { Fragment, startTransition, useActionState, useRef } from "react";
|
|
4
|
+
import { getDirtyFormData } from "../../utils/dirty-form.js";
|
|
5
|
+
import { FormContext } from "./FormContext.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/components/form/BaseForm.tsx
|
|
8
|
+
const INITIAL_STATE = {
|
|
9
|
+
result: { status: "idle" },
|
|
10
|
+
submissionId: 0,
|
|
11
|
+
resetCount: 0
|
|
12
|
+
};
|
|
13
|
+
const NO_FIELD_ERRORS = {};
|
|
14
|
+
const formatAsIs = (code) => code;
|
|
15
|
+
const BaseForm = ({ action, formatMessage = formatAsIs, defaultValues = {}, onlyDirty = false, resetOnSuccess = false, onResult, onSubmit, children, ...otherProps }) => {
|
|
16
|
+
const submit = async (previous, formData) => {
|
|
17
|
+
const result = await action(previous.result, formData);
|
|
18
|
+
onResult?.(result);
|
|
19
|
+
return {
|
|
20
|
+
result,
|
|
21
|
+
submissionId: previous.submissionId + 1,
|
|
22
|
+
resetCount: resetOnSuccess && result.status === "success" ? previous.resetCount + 1 : previous.resetCount
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const [{ result: state, submissionId, resetCount }, formAction, pending] = useActionState(submit, INITIAL_STATE);
|
|
26
|
+
const fieldsRef = useRef(/* @__PURE__ */ new Set());
|
|
27
|
+
const registerField = (fieldName) => {
|
|
28
|
+
fieldsRef.current.add(fieldName);
|
|
29
|
+
};
|
|
30
|
+
const unregisterField = (fieldName) => {
|
|
31
|
+
fieldsRef.current.delete(fieldName);
|
|
32
|
+
};
|
|
33
|
+
const fieldErrors = state.status === "failure" ? state.fieldErrors : NO_FIELD_ERRORS;
|
|
34
|
+
const mountedFieldErrors = {};
|
|
35
|
+
const messages = [];
|
|
36
|
+
if (state.status === "failure" && state.message) messages.push({
|
|
37
|
+
key: "message",
|
|
38
|
+
type: state.message.type,
|
|
39
|
+
text: formatMessage(state.message.text)
|
|
40
|
+
});
|
|
41
|
+
for (const [fieldName, errors] of Object.entries(fieldErrors)) {
|
|
42
|
+
const texts = errors.map((error) => formatMessage(error.code, error.params));
|
|
43
|
+
if (fieldsRef.current.has(fieldName)) mountedFieldErrors[fieldName] = texts;
|
|
44
|
+
else texts.forEach((text, index) => {
|
|
45
|
+
messages.push({
|
|
46
|
+
key: `field:${fieldName}:${index}`,
|
|
47
|
+
type: "error",
|
|
48
|
+
text
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ jsx(Form, {
|
|
53
|
+
...otherProps,
|
|
54
|
+
errors: mountedFieldErrors,
|
|
55
|
+
onSubmit: (e) => {
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
onSubmit?.(e);
|
|
58
|
+
if (e.defaultPrevented) return;
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
const form = e.currentTarget;
|
|
61
|
+
const formData = onlyDirty ? getDirtyFormData(form, defaultValues) : new FormData(form, e.nativeEvent.submitter);
|
|
62
|
+
startTransition(() => formAction(formData));
|
|
63
|
+
},
|
|
64
|
+
children: /* @__PURE__ */ jsx(FormContext, {
|
|
65
|
+
value: {
|
|
66
|
+
fieldErrors,
|
|
67
|
+
messages,
|
|
68
|
+
submissionId,
|
|
69
|
+
formatMessage,
|
|
70
|
+
pending,
|
|
71
|
+
registerField,
|
|
72
|
+
unregisterField
|
|
73
|
+
},
|
|
74
|
+
children: /* @__PURE__ */ jsx(Fragment, { children }, resetCount)
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export { BaseForm as default };
|