@omer-x/tailwind-ui-kit 1.0.0-alpha.2 → 1.0.0-alpha.21

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 (73) hide show
  1. package/MIGRATION.md +247 -0
  2. package/README.md +460 -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/AnimatedPopup.d.ts +7 -6
  8. package/dist/components/dialog/AnimatedPopup.js +8 -33
  9. package/dist/components/dialog/DialogBackdrop.d.ts +7 -6
  10. package/dist/components/dialog/DialogBackdrop.js +7 -24
  11. package/dist/components/dialog/DialogTitle.d.ts +7 -6
  12. package/dist/components/dialog/DialogTitle.js +7 -17
  13. package/dist/components/dialog/index.d.ts +4 -5
  14. package/dist/components/dialog/index.js +4 -8
  15. package/dist/components/elements/JustAnchor.d.ts +7 -0
  16. package/dist/components/elements/JustAnchor.js +10 -0
  17. package/dist/components/elements/JustButton.d.ts +7 -0
  18. package/dist/components/elements/JustButton.js +10 -0
  19. package/dist/components/elements/JustDiv.d.ts +7 -0
  20. package/dist/components/elements/JustDiv.js +10 -0
  21. package/dist/components/elements/JustInput.d.ts +7 -0
  22. package/dist/components/elements/JustInput.js +10 -0
  23. package/dist/components/elements/JustSpan.d.ts +7 -0
  24. package/dist/components/elements/JustSpan.js +10 -0
  25. package/dist/components/form/BaseForm.d.ts +13 -0
  26. package/dist/components/form/BaseForm.js +78 -0
  27. package/dist/components/form/BaseFormField.d.ts +24 -0
  28. package/dist/components/form/BaseFormField.js +32 -0
  29. package/dist/components/form/BaseInput.d.ts +7 -0
  30. package/dist/components/form/BaseInput.js +21 -0
  31. package/dist/components/form/BaseSwitch.d.ts +33 -0
  32. package/dist/components/form/BaseSwitch.js +20 -0
  33. package/dist/components/form/ClientSideError.d.ts +9 -0
  34. package/dist/components/form/ClientSideError.js +39 -0
  35. package/dist/components/form/FieldRoot.d.ts +8 -0
  36. package/dist/components/form/FieldRoot.js +21 -0
  37. package/dist/components/form/FormContext.d.ts +28 -0
  38. package/dist/components/form/FormContext.js +12 -0
  39. package/dist/components/form/ServerSideError.d.ts +8 -0
  40. package/dist/components/form/ServerSideError.js +15 -0
  41. package/dist/components/form/index.d.ts +7 -0
  42. package/dist/components/form/index.js +6 -0
  43. package/dist/components/form/useFormMessages.d.ts +10 -0
  44. package/dist/components/form/useFormMessages.js +16 -0
  45. package/dist/components/layout/Container.d.ts +5 -8
  46. package/dist/components/layout/Container.js +8 -10
  47. package/dist/components/layout/index.d.ts +2 -3
  48. package/dist/components/layout/index.js +1 -4
  49. package/dist/components/page/Pagination.d.ts +21 -0
  50. package/dist/components/page/Pagination.js +65 -0
  51. package/dist/components/page/index.d.ts +3 -0
  52. package/dist/components/page/index.js +3 -0
  53. package/dist/components/page/usePagination.d.ts +30 -0
  54. package/dist/components/page/usePagination.js +41 -0
  55. package/dist/components/table/Tdx.d.ts +5 -8
  56. package/dist/components/table/Tdx.js +13 -9
  57. package/dist/components/table/index.d.ts +2 -3
  58. package/dist/components/table/index.js +1 -4
  59. package/dist/hooks/useRipples.d.ts +2 -0
  60. package/dist/hooks/useRipples.js +49 -0
  61. package/dist/styles/ripple.module.css +1 -0
  62. package/dist/utils/cn.d.ts +6 -5
  63. package/dist/utils/cn.js +8 -6
  64. package/dist/utils/dirty-form.d.ts +7 -0
  65. package/dist/utils/dirty-form.js +40 -0
  66. package/dist/utils/index.d.ts +3 -2
  67. package/dist/utils/index.js +2 -3
  68. package/dist/utils/render.d.ts +31 -0
  69. package/dist/utils/render.js +24 -0
  70. package/package.json +38 -23
  71. package/dist/components/button/PulseButton.d.ts +0 -10
  72. package/dist/components/button/PulseButton.js +0 -24
  73. package/dist/styles/ripple.module.d.ts +0 -2
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { Field } from "@base-ui/react/field";
3
+ import { use } from "react";
4
+ import { FormContext } from "./FormContext.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/form/ServerSideError.tsx
7
+ const ServerSideError = ({ name, render }) => {
8
+ const { fieldErrors, formatMessage } = use(FormContext);
9
+ return (Object.hasOwn(fieldErrors, name) ? fieldErrors[name] : []).map((error, index) => /* @__PURE__ */ jsx(Field.Error, {
10
+ match: true,
11
+ render,
12
+ children: formatMessage(error.code, error.params)
13
+ }, `${index}:${error.code}`));
14
+ };
15
+ export { ServerSideError as default };
@@ -0,0 +1,7 @@
1
+ import BaseInput from "./BaseInput.js";
2
+ import BaseSwitch, { SwitchState } from "./BaseSwitch.js";
3
+ import BaseForm from "./BaseForm.js";
4
+ import BaseFormField, { FieldState } from "./BaseFormField.js";
5
+ import useFormMessages from "./useFormMessages.js";
6
+ import { DisplayedFormMessage, MessageFormatter } from "./FormContext.js";
7
+ export { BaseForm, BaseFormField, BaseInput, BaseSwitch, type DisplayedFormMessage, type FieldState, type MessageFormatter, type SwitchState, useFormMessages };
@@ -0,0 +1,6 @@
1
+ import BaseInput from "./BaseInput.js";
2
+ import BaseSwitch from "./BaseSwitch.js";
3
+ import BaseForm from "./BaseForm.js";
4
+ import BaseFormField from "./BaseFormField.js";
5
+ import useFormMessages from "./useFormMessages.js";
6
+ export { BaseForm, BaseFormField, BaseInput, BaseSwitch, useFormMessages };
@@ -0,0 +1,10 @@
1
+ import { DisplayedFormMessage } from "./FormContext.js";
2
+ /**
3
+ * Returns the form-level messages of the latest result of the surrounding `BaseForm`:
4
+ * the action's message, plus field errors that have no field in the form.
5
+ * `submissionId` changes once per completed submission, e.g. to fire toasts only once.
6
+ */
7
+ export default function useFormMessages(): {
8
+ messages: DisplayedFormMessage[];
9
+ submissionId: number;
10
+ };
@@ -0,0 +1,16 @@
1
+ import { use } from "react";
2
+ import { FormContext } from "./FormContext.js";
3
+ // src/components/form/useFormMessages.ts
4
+ /**
5
+ * Returns the form-level messages of the latest result of the surrounding `BaseForm`:
6
+ * the action's message, plus field errors that have no field in the form.
7
+ * `submissionId` changes once per completed submission, e.g. to fire toasts only once.
8
+ */
9
+ function useFormMessages() {
10
+ const { messages, submissionId } = use(FormContext);
11
+ return {
12
+ messages,
13
+ submissionId
14
+ };
15
+ }
16
+ export { useFormMessages as default };
@@ -1,10 +1,7 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ComponentProps, ReactNode } from 'react';
3
-
1
+ import { ComponentProps, ReactNode } from "react";
4
2
  type ContainerProps = ComponentProps<"div"> & {
5
- className?: string;
6
- children: ReactNode;
3
+ className?: string;
4
+ children: ReactNode;
7
5
  };
8
- declare const Container: ({ className, children, }: ContainerProps) => react_jsx_runtime.JSX.Element;
9
-
10
- export { Container as default };
6
+ declare const Container: ({ className, children }: ContainerProps) => import("react").JSX.Element;
7
+ export { Container as default };
@@ -1,11 +1,9 @@
1
+ import { cn } from "cn";
2
+ import "react";
1
3
  import { jsx } from "react/jsx-runtime";
2
- import {} from "react";
3
- import { cn } from "../../utils/cn.js";
4
- const Container = ({
5
- className,
6
- children
7
- }) => /* @__PURE__ */ jsx("div", { className: cn("container mx-auto px-3", className), children });
8
- var Container_default = Container;
9
- export {
10
- Container_default as default
11
- };
4
+ // src/components/layout/Container.tsx
5
+ const Container = ({ className, children }) => /* @__PURE__ */ jsx("div", {
6
+ className: cn("container mx-auto px-3", className),
7
+ children
8
+ });
9
+ export { Container as default };
@@ -1,3 +1,2 @@
1
- export { default as Container } from './Container.js';
2
- import 'react/jsx-runtime';
3
- import 'react';
1
+ import Container from "./Container.js";
2
+ export { Container };
@@ -1,4 +1 @@
1
- import { default as default2 } from "./Container.js";
2
- export {
3
- default2 as Container
4
- };
1
+ export { default as Container } from "./Container.js";
@@ -0,0 +1,21 @@
1
+ import { ComponentProps, ReactElement, ReactNode } from "react";
2
+ import JustButton from "../elements/JustButton.js";
3
+ import JustSpan from "../elements/JustSpan.js";
4
+ import { PaginationOptions } from "./usePagination.js";
5
+ export type PaginationLinkProps = {
6
+ "children": ReactNode;
7
+ "aria-label"?: string;
8
+ "aria-current"?: "page";
9
+ };
10
+ type PaginationProps = Omit<ComponentProps<"nav">, "children"> & PaginationOptions & {
11
+ /** Builds the link to a page. Spread `props` onto it. It can also be a `<button onClick>` */
12
+ renderLink: (page: number, props: PaginationLinkProps) => ReactElement;
13
+ /** Renders a disabled arrow (a disabled `<button>`) */
14
+ renderButton?: ComponentProps<typeof JustButton>["render"];
15
+ /** Renders an ellipsis (a `<span>`) */
16
+ renderEllipsis?: ComponentProps<typeof JustSpan>["render"];
17
+ previousLabel?: string;
18
+ nextLabel?: string;
19
+ };
20
+ declare const Pagination: ({ totalItems, itemsPerPage, currentPage, siblings, renderLink, renderButton, renderEllipsis, previousLabel, nextLabel, className, ...otherProps }: PaginationProps) => import("react").JSX.Element;
21
+ export { Pagination as default };
@@ -0,0 +1,65 @@
1
+ import { cn } from "cn";
2
+ import "react";
3
+ import JustButton from "../elements/JustButton.js";
4
+ import JustSpan from "../elements/JustSpan.js";
5
+ import usePagination from "./usePagination.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/page/Pagination.tsx
8
+ const PaginationItemView = ({ item, renderLink, renderButton, renderEllipsis, previousLabel, nextLabel }) => {
9
+ switch (item.type) {
10
+ case "ellipsis": return /* @__PURE__ */ jsx(JustSpan, {
11
+ render: renderEllipsis,
12
+ "aria-hidden": true,
13
+ children: "…"
14
+ });
15
+ case "page": return renderLink(item.page, {
16
+ "children": item.page,
17
+ "aria-current": item.current ? "page" : void 0
18
+ });
19
+ case "previous":
20
+ case "next": {
21
+ const label = item.type === "previous" ? previousLabel : nextLabel;
22
+ const children = item.type === "previous" ? "«" : "»";
23
+ if (item.disabled) return /* @__PURE__ */ jsx(JustButton, {
24
+ render: renderButton,
25
+ type: "button",
26
+ "aria-label": label,
27
+ disabled: true,
28
+ children
29
+ });
30
+ return renderLink(item.page, {
31
+ children,
32
+ "aria-label": label
33
+ });
34
+ }
35
+ }
36
+ };
37
+ const itemKey = (item, index) => {
38
+ switch (item.type) {
39
+ case "page": return `page-${item.page}`;
40
+ case "ellipsis": return `ellipsis-${index}`;
41
+ default: return item.type;
42
+ }
43
+ };
44
+ const Pagination = ({ totalItems, itemsPerPage, currentPage, siblings, renderLink, renderButton, renderEllipsis, previousLabel = "Previous page", nextLabel = "Next page", className, ...otherProps }) => {
45
+ const items = usePagination({
46
+ totalItems,
47
+ itemsPerPage,
48
+ currentPage,
49
+ siblings
50
+ });
51
+ return /* @__PURE__ */ jsx("nav", {
52
+ "aria-label": "Pagination",
53
+ ...otherProps,
54
+ className: cn("flex gap-3", className),
55
+ children: items.map((item, index) => /* @__PURE__ */ jsx(PaginationItemView, {
56
+ item,
57
+ renderLink,
58
+ renderButton,
59
+ renderEllipsis,
60
+ previousLabel,
61
+ nextLabel
62
+ }, itemKey(item, index)))
63
+ });
64
+ };
65
+ export { Pagination as default };
@@ -0,0 +1,3 @@
1
+ import Pagination, { PaginationLinkProps } from "./Pagination.js";
2
+ import usePagination, { PaginationItem, PaginationOptions } from "./usePagination.js";
3
+ export { Pagination, type PaginationItem, type PaginationLinkProps, type PaginationOptions, usePagination };
@@ -0,0 +1,3 @@
1
+ import Pagination from "./Pagination.js";
2
+ import usePagination from "./usePagination.js";
3
+ export { Pagination, usePagination };
@@ -0,0 +1,30 @@
1
+ export type PaginationOptions = {
2
+ totalItems: number;
3
+ itemsPerPage: number;
4
+ currentPage: number;
5
+ /** Pages shown on each side of the current one (default 2) */
6
+ siblings?: number;
7
+ };
8
+ type ArrowItem = {
9
+ type: "previous" | "next";
10
+ page: number;
11
+ disabled: boolean;
12
+ };
13
+ type PageItem = {
14
+ type: "page";
15
+ page: number;
16
+ current: boolean;
17
+ };
18
+ type EllipsisItem = {
19
+ type: "ellipsis";
20
+ };
21
+ export type PaginationItem = ArrowItem | PageItem | EllipsisItem;
22
+ /**
23
+ * Decides which pages to show: previous/next arrows, the first and last pages,
24
+ * `siblings` pages on each side of the current one, and ellipses for gaps.
25
+ * A gap of a single page shows that page instead of an ellipsis.
26
+ *
27
+ * It holds no state, so it also works in server components.
28
+ */
29
+ declare const usePagination: ({ totalItems, itemsPerPage, currentPage, siblings }: PaginationOptions) => PaginationItem[];
30
+ export { usePagination as default };
@@ -0,0 +1,41 @@
1
+ // src/components/page/usePagination.ts
2
+ /**
3
+ * Decides which pages to show: previous/next arrows, the first and last pages,
4
+ * `siblings` pages on each side of the current one, and ellipses for gaps.
5
+ * A gap of a single page shows that page instead of an ellipsis.
6
+ *
7
+ * It holds no state, so it also works in server components.
8
+ */
9
+ const usePagination = ({ totalItems, itemsPerPage, currentPage, siblings = 2 }) => {
10
+ const totalPages = Math.max(1, Math.ceil(totalItems / itemsPerPage));
11
+ const start = Math.max(1, currentPage - siblings);
12
+ const end = Math.min(totalPages, currentPage + siblings);
13
+ const page = (n) => ({
14
+ type: "page",
15
+ page: n,
16
+ current: n === currentPage
17
+ });
18
+ const items = [{
19
+ type: "previous",
20
+ page: currentPage - 1,
21
+ disabled: currentPage <= 1
22
+ }];
23
+ if (start > 1) {
24
+ items.push(page(1));
25
+ if (start === 3) items.push(page(2));
26
+ if (start > 3) items.push({ type: "ellipsis" });
27
+ }
28
+ for (let n = start; n <= end; n++) items.push(page(n));
29
+ if (end < totalPages) {
30
+ if (end < totalPages - 2) items.push({ type: "ellipsis" });
31
+ if (end === totalPages - 2) items.push(page(totalPages - 1));
32
+ items.push(page(totalPages));
33
+ }
34
+ items.push({
35
+ type: "next",
36
+ page: currentPage + 1,
37
+ disabled: currentPage >= totalPages
38
+ });
39
+ return items;
40
+ };
41
+ export { usePagination as default };
@@ -1,10 +1,7 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
-
1
+ import { ReactNode } from "react";
4
2
  type TdxProps = {
5
- className?: string;
6
- children?: ReactNode;
3
+ className?: string;
4
+ children?: ReactNode;
7
5
  };
8
- declare const Tdx: ({ className, children, }: TdxProps) => react_jsx_runtime.JSX.Element;
9
-
10
- export { Tdx as default };
6
+ declare const Tdx: ({ className, children }: TdxProps) => import("react").JSX.Element;
7
+ export { Tdx as default };
@@ -1,10 +1,14 @@
1
+ import "react";
1
2
  import { jsx } from "react/jsx-runtime";
2
- import {} from "react";
3
- const Tdx = ({
4
- className,
5
- children
6
- }) => /* @__PURE__ */ jsx("td", { className, children: /* @__PURE__ */ jsx("div", { className: "table w-full table-fixed", children: /* @__PURE__ */ jsx("span", { className: "table-cell truncate", children }) }) });
7
- var Tdx_default = Tdx;
8
- export {
9
- Tdx_default as default
10
- };
3
+ // src/components/table/Tdx.tsx
4
+ const Tdx = ({ className, children }) => /* @__PURE__ */ jsx("td", {
5
+ className,
6
+ children: /* @__PURE__ */ jsx("div", {
7
+ className: "table w-full table-fixed",
8
+ children: /* @__PURE__ */ jsx("span", {
9
+ className: "table-cell truncate",
10
+ children
11
+ })
12
+ })
13
+ });
14
+ export { Tdx as default };
@@ -1,3 +1,2 @@
1
- export { default as Tdx } from './Tdx.js';
2
- import 'react/jsx-runtime';
3
- import 'react';
1
+ import Tdx from "./Tdx.js";
2
+ export { Tdx };
@@ -1,4 +1 @@
1
- import { default as default2 } from "./Tdx.js";
2
- export {
3
- default2 as Tdx
4
- };
1
+ export { default as Tdx } from "./Tdx.js";
@@ -0,0 +1,2 @@
1
+ import { MouseEvent } from "react";
2
+ export declare function useRipples(): readonly [(e: MouseEvent<Element>) => void, import("react").JSX.Element];
@@ -0,0 +1,49 @@
1
+ import { cn } from "cn";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import styles from "../styles/ripple.module.css";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/hooks/useRipples.tsx
6
+ const RIPPLE_DURATION = 600;
7
+ function useRipples() {
8
+ const [ripples, setRipples] = useState([]);
9
+ const nextId = useRef(0);
10
+ const timeouts = useRef(/* @__PURE__ */ new Set());
11
+ useEffect(() => {
12
+ const pending = timeouts.current;
13
+ return () => {
14
+ pending.forEach(clearTimeout);
15
+ };
16
+ }, []);
17
+ const handleClick = (e) => {
18
+ const rect = e.currentTarget.getBoundingClientRect();
19
+ const size = Math.max(rect.width, rect.height);
20
+ const fromKeyboard = e.detail === 0;
21
+ const x = fromKeyboard ? rect.width / 2 - size / 2 : e.clientX - rect.left - size / 2;
22
+ const y = fromKeyboard ? rect.height / 2 - size / 2 : e.clientY - rect.top - size / 2;
23
+ const id = nextId.current++;
24
+ setRipples((prev) => [...prev, {
25
+ x,
26
+ y,
27
+ size,
28
+ id
29
+ }]);
30
+ const timeout = setTimeout(() => {
31
+ timeouts.current.delete(timeout);
32
+ setRipples((prev) => prev.filter((r) => r.id !== id));
33
+ }, RIPPLE_DURATION);
34
+ timeouts.current.add(timeout);
35
+ };
36
+ return [handleClick, /* @__PURE__ */ jsx("div", {
37
+ className: "absolute inset-0 pointer-events-none overflow-hidden rounded-[inherit] motion-reduce:hidden",
38
+ children: ripples.map((ripple) => /* @__PURE__ */ jsx("span", {
39
+ className: cn(styles.animation, "absolute rounded-full bg-current opacity-10"),
40
+ style: {
41
+ left: ripple.x,
42
+ top: ripple.y,
43
+ width: ripple.size,
44
+ height: ripple.size
45
+ }
46
+ }, ripple.id))
47
+ })];
48
+ }
49
+ export { useRipples };
@@ -4,6 +4,7 @@
4
4
  opacity: 0;
5
5
  }
6
6
  }
7
+
7
8
  .animation {
8
9
  animation: ripple 600ms linear;
9
10
  transform: scale(0);
@@ -1,5 +1,6 @@
1
- import { ClassValue } from 'clsx';
2
-
3
- declare function cn(...inputs: ClassValue[]): string;
4
-
5
- export { cn };
1
+ import { cn as cn$1 } from "cn";
2
+ /**
3
+ * @deprecated Use `cn` from the `cn` package directly instead:
4
+ * `import { cn } from "cn";`
5
+ */
6
+ export declare function cn(...inputs: Parameters<typeof cn$1>): string;
package/dist/utils/cn.js CHANGED
@@ -1,8 +1,10 @@
1
- import { clsx } from "clsx";
2
- import { twMerge } from "tailwind-merge";
1
+ import { cn as cn$1 } from "cn";
2
+ // src/utils/cn.ts
3
+ /**
4
+ * @deprecated Use `cn` from the `cn` package directly instead:
5
+ * `import { cn } from "cn";`
6
+ */
3
7
  function cn(...inputs) {
4
- return twMerge(clsx(inputs));
8
+ return cn$1(...inputs);
5
9
  }
6
- export {
7
- cn
8
- };
10
+ export { cn };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Builds the form data of the fields whose value differs from `defaultValues`.
3
+ * Fields are compared by name, so multi-selects, checkbox groups and file inputs are handled as a whole.
4
+ * A changed field with no value (an unchecked checkbox, a cleared multi-select) is sent as an empty value,
5
+ * so the server can tell it apart from an unchanged field.
6
+ */
7
+ export declare function getDirtyFormData(form: HTMLFormElement, defaultValues: Record<string, unknown>): FormData;
@@ -0,0 +1,40 @@
1
+ // src/utils/dirty-form.ts
2
+ function hasValue(value) {
3
+ return typeof value === "string" ? value !== "" : value.name !== "";
4
+ }
5
+ function normalizeDefault(defaultValue) {
6
+ if (defaultValue === void 0 || defaultValue === null) return [];
7
+ return (Array.isArray(defaultValue) ? defaultValue : [defaultValue]).map((value) => typeof value === "object" && value !== null ? JSON.stringify(value) : String(value)).filter((value) => value !== "");
8
+ }
9
+ function isChecked(form, name) {
10
+ return Array.from(form.elements).some((e) => e instanceof HTMLInputElement && e.name === name && (e.type === "checkbox" || e.type === "radio") && e.checked);
11
+ }
12
+ function isDirty(form, name, defaultValue, values) {
13
+ if (typeof defaultValue === "boolean") return isChecked(form, name) !== defaultValue;
14
+ if (values.some((value) => typeof value !== "string")) return true;
15
+ const current = values.toSorted();
16
+ const defaults = normalizeDefault(defaultValue).toSorted();
17
+ return current.length !== defaults.length || current.some((value, index) => value !== defaults[index]);
18
+ }
19
+ /**
20
+ * Builds the form data of the fields whose value differs from `defaultValues`.
21
+ * Fields are compared by name, so multi-selects, checkbox groups and file inputs are handled as a whole.
22
+ * A changed field with no value (an unchecked checkbox, a cleared multi-select) is sent as an empty value,
23
+ * so the server can tell it apart from an unchanged field.
24
+ */
25
+ function getDirtyFormData(form, defaultValues) {
26
+ const formData = new FormData(form);
27
+ const names = /* @__PURE__ */ new Set();
28
+ for (const e of Array.from(form.elements)) if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) {
29
+ if (e.name) names.add(e.name);
30
+ }
31
+ const dirty = new FormData();
32
+ for (const name of names) {
33
+ const values = formData.getAll(name).filter(hasValue);
34
+ if (!isDirty(form, name, defaultValues[name], values)) continue;
35
+ if (values.length === 0) dirty.append(name, "");
36
+ for (const value of values) dirty.append(name, value);
37
+ }
38
+ return dirty;
39
+ }
40
+ export { getDirtyFormData };
@@ -1,2 +1,3 @@
1
- export { cn } from './cn.js';
2
- import 'clsx';
1
+ import { cn } from "./cn.js";
2
+ import { IntrinsicTag, RenderProp, UseRenderOptions, mergeProps, useRender } from "./render.js";
3
+ export { type IntrinsicTag, type RenderProp, type UseRenderOptions, cn, mergeProps, useRender };
@@ -1,4 +1,3 @@
1
1
  import { cn } from "./cn.js";
2
- export {
3
- cn
4
- };
2
+ import { mergeProps, useRender } from "./render.js";
3
+ export { cn, mergeProps, useRender };
@@ -0,0 +1,31 @@
1
+ import { ComponentPropsWithRef, JSX, ReactElement } from "react";
2
+ export type IntrinsicTag = keyof JSX.IntrinsicElements;
3
+ type RenderFunction<Tag extends IntrinsicTag, State> = (props: ComponentPropsWithRef<Tag>, state: State) => ReactElement;
4
+ /**
5
+ * Replaces the element a component renders.
6
+ * An element is rendered with the component's props merged into it.
7
+ * A function gets those props (spread them onto your element) and the component's state.
8
+ */
9
+ export type RenderProp<Tag extends IntrinsicTag, State = object> = ReactElement | RenderFunction<Tag, State>;
10
+ export type UseRenderOptions<Tag extends IntrinsicTag, State extends object> = {
11
+ /** The element rendered when `render` is missing. */
12
+ defaultTagName: Tag;
13
+ render?: RenderProp<Tag, State>;
14
+ /** Props of the rendered element. They are merged into the `render` element's own props. */
15
+ props?: ComponentPropsWithRef<Tag>;
16
+ /** Passed to a `render` function, and set as data attributes (`{ checked: true }` → `data-checked`). */
17
+ state?: State;
18
+ };
19
+ /**
20
+ * Renders `defaultTagName`, or the element given by `render`, with `props` merged into it.
21
+ * Build a component that takes a `render` prop with it.
22
+ */
23
+ export declare function useRender<Tag extends IntrinsicTag, State extends object = object>({ defaultTagName, render, props, state }: UseRenderOptions<Tag, State>): ReactElement;
24
+ type Props<Tag extends IntrinsicTag> = ComponentPropsWithRef<Tag>;
25
+ /**
26
+ * Merges props for one element, later ones winning.
27
+ * Event handlers are chained (later ones run first), `className`s are joined and `style`s are merged.
28
+ * `ref` is not merged.
29
+ */
30
+ export declare function mergeProps<Tag extends IntrinsicTag>(...props: (Props<Tag> | undefined)[]): Props<Tag>;
31
+ export {};
@@ -0,0 +1,24 @@
1
+ import { mergePropsN } from "@base-ui/react/merge-props";
2
+ import { useRender as useRender$1 } from "@base-ui/react/use-render";
3
+ // src/utils/render.ts
4
+ /**
5
+ * Renders `defaultTagName`, or the element given by `render`, with `props` merged into it.
6
+ * Build a component that takes a `render` prop with it.
7
+ */
8
+ function useRender({ defaultTagName, render, props, state }) {
9
+ return useRender$1({
10
+ defaultTagName,
11
+ render,
12
+ props,
13
+ state
14
+ });
15
+ }
16
+ /**
17
+ * Merges props for one element, later ones winning.
18
+ * Event handlers are chained (later ones run first), `className`s are joined and `style`s are merged.
19
+ * `ref` is not merged.
20
+ */
21
+ function mergeProps(...props) {
22
+ return mergePropsN(props);
23
+ }
24
+ export { mergeProps, useRender };