@omer-x/tailwind-ui-kit 1.0.0-alpha.17 → 1.0.0-alpha.19

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 (67) hide show
  1. package/MIGRATION.md +164 -0
  2. package/README.md +390 -0
  3. package/dist/components/button/BaseButton.d.ts +27 -11
  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 +3 -6
  8. package/dist/components/dialog/AnimatedPopup.js +6 -31
  9. package/dist/components/dialog/DialogBackdrop.d.ts +3 -6
  10. package/dist/components/dialog/DialogBackdrop.js +6 -22
  11. package/dist/components/dialog/DialogTitle.d.ts +3 -6
  12. package/dist/components/dialog/DialogTitle.js +6 -15
  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 +3 -6
  16. package/dist/components/elements/JustAnchor.js +8 -13
  17. package/dist/components/elements/JustButton.d.ts +3 -6
  18. package/dist/components/elements/JustButton.js +8 -13
  19. package/dist/components/elements/JustDiv.d.ts +3 -6
  20. package/dist/components/elements/JustDiv.js +8 -13
  21. package/dist/components/elements/JustInput.d.ts +3 -6
  22. package/dist/components/elements/JustInput.js +8 -13
  23. package/dist/components/form/BaseForm.d.ts +12 -15
  24. package/dist/components/form/BaseForm.js +72 -70
  25. package/dist/components/form/BaseFormField.d.ts +12 -19
  26. package/dist/components/form/BaseFormField.js +29 -24
  27. package/dist/components/form/BaseInput.d.ts +5 -9
  28. package/dist/components/form/BaseInput.js +20 -31
  29. package/dist/components/form/BaseSwitch.d.ts +6 -9
  30. package/dist/components/form/BaseSwitch.js +18 -51
  31. package/dist/components/form/ClientSideError.d.ts +9 -0
  32. package/dist/components/form/ClientSideError.js +39 -0
  33. package/dist/components/form/FieldRoot.d.ts +6 -9
  34. package/dist/components/form/FieldRoot.js +16 -18
  35. package/dist/components/form/FormContext.d.ts +26 -9
  36. package/dist/components/form/FormContext.js +9 -7
  37. package/dist/components/form/ServerSideError.d.ts +6 -10
  38. package/dist/components/form/ServerSideError.js +10 -14
  39. package/dist/components/form/index.d.ts +7 -11
  40. package/dist/components/form/index.js +6 -10
  41. package/dist/components/form/useFormMessages.d.ts +10 -0
  42. package/dist/components/form/useFormMessages.js +16 -0
  43. package/dist/components/layout/Container.d.ts +5 -8
  44. package/dist/components/layout/Container.js +8 -10
  45. package/dist/components/layout/index.d.ts +2 -2
  46. package/dist/components/layout/index.js +1 -4
  47. package/dist/components/page/Pagination.d.ts +11 -15
  48. package/dist/components/page/Pagination.js +60 -48
  49. package/dist/components/page/index.d.ts +2 -5
  50. package/dist/components/page/index.js +1 -4
  51. package/dist/components/table/Tdx.d.ts +5 -8
  52. package/dist/components/table/Tdx.js +13 -9
  53. package/dist/components/table/index.d.ts +2 -2
  54. package/dist/components/table/index.js +1 -4
  55. package/dist/hooks/useRipples.d.ts +2 -5
  56. package/dist/hooks/useRipples.js +46 -33
  57. package/dist/styles/ripple.module.css +1 -0
  58. package/dist/utils/cn.d.ts +6 -5
  59. package/dist/utils/cn.js +8 -6
  60. package/dist/utils/dirty-form.d.ts +1 -3
  61. package/dist/utils/dirty-form.js +24 -39
  62. package/dist/utils/index.d.ts +2 -2
  63. package/dist/utils/index.js +1 -4
  64. package/package.json +27 -24
  65. package/dist/components/button/PulseButton.d.ts +0 -8
  66. package/dist/components/button/PulseButton.js +0 -41
  67. package/dist/styles/ripple.module.d.ts +0 -2
@@ -1,21 +1,14 @@
1
- import * as react from 'react';
2
- import { ComponentProps } from 'react';
3
- import { Field } from '@base-ui/react/field';
4
- import JustInput from '../elements/JustInput.js';
5
- import { ZodType } from 'zod';
6
- import '@base-ui/react/use-render';
7
-
1
+ import { Field } from "@base-ui/react/field";
2
+ import { ComponentProps } from "react";
3
+ import { ZodType } from "zod";
8
4
  type BaseFormFieldProps = {
9
- schema: ZodType;
10
- name: string;
11
- label?: string;
12
- messages?: Partial<Record<string, string>>;
13
- control?: ComponentProps<typeof JustInput>["render"];
14
- renderLabel?: ComponentProps<typeof Field.Label>["render"];
15
- renderErrors?: ComponentProps<typeof Field.Error>["render"];
16
- clientSideErrors?: Partial<Record<keyof ValidityState, string | ((payload: string | number | null) => string)>>;
17
- className?: string;
5
+ schema: ZodType;
6
+ name: string;
7
+ label?: string;
8
+ control?: ComponentProps<typeof Field.Control>["render"];
9
+ renderLabel?: ComponentProps<typeof Field.Label>["render"];
10
+ renderErrors?: ComponentProps<typeof Field.Error>["render"];
11
+ className?: string;
18
12
  };
19
- declare const BaseFormField: ({ schema, name, label, messages, control, renderLabel, renderErrors, clientSideErrors, className, }: BaseFormFieldProps) => react.JSX.Element;
20
-
21
- export { BaseFormField as default };
13
+ declare const BaseFormField: ({ schema, name, label, control, renderLabel, renderErrors, className }: BaseFormFieldProps) => import("react").JSX.Element;
14
+ export { BaseFormField as default };
@@ -1,27 +1,32 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
1
  import { Field } from "@base-ui/react/field";
3
- import { getErrorMessagePayload, getFieldConstraints } from "@omer-x/zod-to-form-constraints";
4
- import { cn } from "../../utils/cn.js";
5
- import JustInput from "../elements/JustInput.js";
2
+ import { getFieldConstraints } from "@omer-x/zod-to-form-constraints";
3
+ import { cn } from "cn";
4
+ import ClientSideError from "./ClientSideError.js";
6
5
  import FieldRoot from "./FieldRoot.js";
7
6
  import ServerSideError from "./ServerSideError.js";
8
- const BaseFormField = ({
9
- schema,
10
- name,
11
- label,
12
- messages,
13
- control,
14
- renderLabel,
15
- renderErrors,
16
- clientSideErrors = {},
17
- className
18
- }) => /* @__PURE__ */ jsxs(FieldRoot, { name, className: cn("flex w-full flex-col items-start gap-1", className), children: [
19
- typeof label !== "undefined" && /* @__PURE__ */ jsx(Field.Label, { render: renderLabel, children: label }),
20
- /* @__PURE__ */ jsx(JustInput, { name, render: control, ...getFieldConstraints(schema) }),
21
- Object.entries(clientSideErrors).map(([stateName, message]) => /* @__PURE__ */ jsx(Field.Error, { match: stateName, render: renderErrors, children: typeof message === "string" ? message : message(getErrorMessagePayload(schema, stateName)) }, stateName)),
22
- /* @__PURE__ */ jsx(ServerSideError, { name, messages, render: renderErrors })
23
- ] });
24
- var BaseFormField_default = BaseFormField;
25
- export {
26
- BaseFormField_default as default
27
- };
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ // src/components/form/BaseFormField.tsx
9
+ const BaseFormField = ({ schema, name, label, control, renderLabel, renderErrors, className }) => /* @__PURE__ */ jsxs(FieldRoot, {
10
+ name,
11
+ className: cn("flex w-full flex-col items-start gap-1", className),
12
+ children: [
13
+ typeof label !== "undefined" && /* @__PURE__ */ jsx(Field.Label, {
14
+ render: renderLabel,
15
+ children: label
16
+ }),
17
+ /* @__PURE__ */ jsx(Field.Control, {
18
+ name,
19
+ render: control,
20
+ ...getFieldConstraints(schema)
21
+ }),
22
+ /* @__PURE__ */ jsx(ClientSideError, {
23
+ schema,
24
+ render: renderErrors
25
+ }),
26
+ /* @__PURE__ */ jsx(ServerSideError, {
27
+ name,
28
+ render: renderErrors
29
+ })
30
+ ]
31
+ });
32
+ export { BaseFormField as default };
@@ -1,11 +1,7 @@
1
- import * as react from 'react';
2
- import { ComponentProps } from 'react';
3
- import JustInput from '../elements/JustInput.js';
4
- import '@base-ui/react/use-render';
5
-
1
+ import { ComponentProps } from "react";
2
+ import JustInput from "../elements/JustInput.js";
6
3
  type BaseInputProps = Omit<ComponentProps<typeof JustInput>, "size"> & {
7
- size?: "lg" | "md" | "sm" | "xs";
4
+ size?: "lg" | "md" | "sm" | "xs";
8
5
  };
9
- declare const BaseInput: ({ size, className, ...otherProps }: BaseInputProps) => react.JSX.Element;
10
-
11
- export { BaseInput as default };
6
+ declare const BaseInput: ({ size, className, ...otherProps }: BaseInputProps) => import("react").JSX.Element;
7
+ export { BaseInput as default };
@@ -1,32 +1,21 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import {} from "react";
3
- import { cn } from "../../utils/cn.js";
1
+ import { cn } from "cn";
2
+ import "react";
4
3
  import JustInput from "../elements/JustInput.js";
5
- const BaseInput = ({
6
- size = "md",
7
- className,
8
- ...otherProps
9
- }) => /* @__PURE__ */ jsx(
10
- JustInput,
11
- {
12
- ...otherProps,
13
- className: cn({
14
- // Size
15
- "h-12 px-5 text-base": size === "lg",
16
- "h-9 px-3 text-sm": size === "md",
17
- "h-8 px-2.5 text-sm": size === "sm",
18
- "h-7 px-2 text-xs": size === "xs"
19
- }, [
20
- // Base
21
- "rounded-md",
22
- "outline-2",
23
- "outline-offset-2",
24
- "outline-transparent",
25
- "transition-colors"
26
- ], className)
27
- }
28
- );
29
- var BaseInput_default = BaseInput;
30
- export {
31
- BaseInput_default as default
32
- };
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/form/BaseInput.tsx
6
+ const BaseInput = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(JustInput, {
7
+ ...otherProps,
8
+ className: cn({
9
+ "h-12 px-5 text-base": size === "lg",
10
+ "h-9 px-3 text-sm": size === "md",
11
+ "h-8 px-2.5 text-sm": size === "sm",
12
+ "h-7 px-2 text-xs": size === "xs"
13
+ }, [
14
+ "rounded-md",
15
+ "outline-2",
16
+ "outline-offset-2",
17
+ "outline-transparent",
18
+ "transition-colors"
19
+ ], className)
20
+ });
21
+ export { BaseInput as default };
@@ -1,11 +1,8 @@
1
- import * as react from 'react';
2
- import { ComponentProps, ReactNode } from 'react';
3
- import { Switch } from '@base-ui/react/switch';
4
-
1
+ import { Switch } from "@base-ui/react/switch";
2
+ import { ComponentProps, ReactNode } from "react";
5
3
  type BaseSwitchProps = ComponentProps<typeof Switch.Root> & {
6
- label: ReactNode;
7
- renderThumb?: ComponentProps<typeof Switch.Thumb>["render"];
4
+ label: ReactNode;
5
+ renderThumb?: ComponentProps<typeof Switch.Thumb>["render"];
8
6
  };
9
- declare const BaseSwitch: ({ label, renderThumb, value, uncheckedValue, className, ...otherProps }: BaseSwitchProps) => react.JSX.Element;
10
-
11
- export { BaseSwitch as default };
7
+ declare const BaseSwitch: ({ label, renderThumb, value, uncheckedValue, className, ...otherProps }: BaseSwitchProps) => import("react").JSX.Element;
8
+ export { BaseSwitch as default };
@@ -1,52 +1,19 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
1
  import { Switch } from "@base-ui/react/switch";
3
- import {} from "react";
4
- import { cn } from "../../utils/cn.js";
5
- const BaseSwitch = ({
6
- label,
7
- renderThumb,
8
- value = "true",
9
- uncheckedValue = "false",
10
- className,
11
- ...otherProps
12
- }) => /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm font-normal", children: [
13
- /* @__PURE__ */ jsx(
14
- Switch.Root,
15
- {
16
- ...otherProps,
17
- value,
18
- uncheckedValue,
19
- className: cn(
20
- "flex",
21
- "h-5",
22
- "w-9",
23
- "shrink-0",
24
- "p-0.5",
25
- "transition-colors",
26
- "duration-150",
27
- "ease-[ease]",
28
- "focus-visible:outline-2",
29
- "focus-visible:outline-offset-2",
30
- className
31
- ),
32
- children: /* @__PURE__ */ jsx(
33
- Switch.Thumb,
34
- {
35
- className: cn(
36
- "size-3.5",
37
- "transition-[translate,background-color]",
38
- "duration-150",
39
- "ease-[ease]",
40
- "data-checked:translate-x-4"
41
- ),
42
- render: renderThumb
43
- }
44
- )
45
- }
46
- ),
47
- label
48
- ] });
49
- var BaseSwitch_default = BaseSwitch;
50
- export {
51
- BaseSwitch_default as default
52
- };
2
+ import { cn } from "cn";
3
+ import "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ // src/components/form/BaseSwitch.tsx
6
+ const BaseSwitch = ({ label, renderThumb, value = "true", uncheckedValue = "false", className, ...otherProps }) => /* @__PURE__ */ jsxs("label", {
7
+ className: "flex items-center gap-2 text-sm font-normal",
8
+ children: [/* @__PURE__ */ jsx(Switch.Root, {
9
+ ...otherProps,
10
+ value,
11
+ uncheckedValue,
12
+ className: cn("flex", "h-5", "w-9", "shrink-0", "p-0.5", "transition-colors", "duration-150", "ease-[ease]", "focus-visible:outline-2", "focus-visible:outline-offset-2", className),
13
+ children: /* @__PURE__ */ jsx(Switch.Thumb, {
14
+ className: cn("size-3.5", "transition-[translate,background-color]", "duration-150", "ease-[ease]", "data-checked:translate-x-4"),
15
+ render: renderThumb
16
+ })
17
+ }), label]
18
+ });
19
+ export { BaseSwitch as default };
@@ -0,0 +1,9 @@
1
+ import { Field } from "@base-ui/react/field";
2
+ import { ComponentProps } from "react";
3
+ import { ZodType } from "zod";
4
+ type ClientSideErrorProps = {
5
+ schema: ZodType;
6
+ render?: ComponentProps<typeof Field.Error>["render"];
7
+ };
8
+ declare const ClientSideError: ({ schema, render }: ClientSideErrorProps) => import("react").JSX.Element[];
9
+ export { ClientSideError as default };
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { Field } from "@base-ui/react/field";
3
+ import { getErrorMessagePayload } from "@omer-x/zod-to-form-constraints";
4
+ import { use } from "react";
5
+ import { FormContext } from "./FormContext.js";
6
+ import { jsx } from "react/jsx-runtime";
7
+ // src/components/form/ClientSideError.tsx
8
+ const VALIDITY_STATES = [
9
+ "valueMissing",
10
+ "typeMismatch",
11
+ "patternMismatch",
12
+ "tooShort",
13
+ "tooLong",
14
+ "rangeUnderflow",
15
+ "rangeOverflow",
16
+ "stepMismatch",
17
+ "badInput"
18
+ ];
19
+ const PARAM_NAMES = {
20
+ tooShort: "minimum",
21
+ rangeUnderflow: "minimum",
22
+ tooLong: "maximum",
23
+ rangeOverflow: "maximum"
24
+ };
25
+ const FormattedError = ({ schema, state }) => {
26
+ const { formatMessage } = use(FormContext);
27
+ const paramName = PARAM_NAMES[state];
28
+ if (!paramName) return formatMessage(state);
29
+ return formatMessage(state, { [paramName]: getErrorMessagePayload(schema, state) });
30
+ };
31
+ const ClientSideError = ({ schema, render }) => VALIDITY_STATES.map((state) => /* @__PURE__ */ jsx(Field.Error, {
32
+ match: state,
33
+ render,
34
+ children: /* @__PURE__ */ jsx(FormattedError, {
35
+ schema,
36
+ state
37
+ })
38
+ }, state));
39
+ export { ClientSideError as default };
@@ -1,11 +1,8 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
-
1
+ import { ReactNode } from "react";
4
2
  type FieldRootProps = {
5
- name: string;
6
- className?: string;
7
- children: ReactNode;
3
+ name: string;
4
+ className?: string;
5
+ children: ReactNode;
8
6
  };
9
- declare const FieldRoot: ({ name, className, children, }: FieldRootProps) => react.JSX.Element;
10
-
11
- export { FieldRoot as default };
7
+ declare const FieldRoot: ({ name, className, children }: FieldRootProps) => import("react").JSX.Element;
8
+ export { FieldRoot as default };
@@ -1,23 +1,21 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
2
  import { Field } from "@base-ui/react/field";
4
3
  import { use, useEffect } from "react";
5
4
  import { FormContext } from "./FormContext.js";
6
- const FieldRoot = ({
7
- name,
8
- className,
9
- children
10
- }) => {
11
- const { registerField, unregisterField } = use(FormContext);
12
- useEffect(() => {
13
- registerField(name);
14
- return () => {
15
- unregisterField(name);
16
- };
17
- }, [name]);
18
- return /* @__PURE__ */ jsx(Field.Root, { name, className, children });
19
- };
20
- var FieldRoot_default = FieldRoot;
21
- export {
22
- FieldRoot_default as default
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/form/FieldRoot.tsx
7
+ const FieldRoot = ({ name, className, children }) => {
8
+ const { registerField, unregisterField } = use(FormContext);
9
+ useEffect(() => {
10
+ registerField(name);
11
+ return () => {
12
+ unregisterField(name);
13
+ };
14
+ }, [name]);
15
+ return /* @__PURE__ */ jsx(Field.Root, {
16
+ name,
17
+ className,
18
+ children
19
+ });
23
20
  };
21
+ export { FieldRoot as default };
@@ -1,11 +1,28 @@
1
- import * as react from 'react';
2
-
1
+ import { FieldError, FormMessage } from "@omer-x/next-form-actions";
2
+ /**
3
+ * Turns an error code (a server error code, a browser validity state or a form message text)
4
+ * and its params into display text.
5
+ */
6
+ export type MessageFormatter = (code: string, params?: Record<string, unknown>) => string;
7
+ /**
8
+ * A form-level message of the latest result, already formatted.
9
+ */
10
+ export type DisplayedFormMessage = {
11
+ /**
12
+ * Stable within one result, for use as a React key.
13
+ */
14
+ key: string;
15
+ type: FormMessage["type"];
16
+ text: string;
17
+ };
3
18
  interface FormContextInterface {
4
- getFieldMessage: (fieldName: string) => string | null;
5
- messageTranslations: Partial<Record<string, string>>;
6
- registerField: (fieldName: string) => void;
7
- unregisterField: (fieldName: string) => void;
19
+ fieldErrors: Record<string, FieldError[]>;
20
+ messages: DisplayedFormMessage[];
21
+ submissionId: number;
22
+ formatMessage: MessageFormatter;
23
+ pending: boolean;
24
+ registerField: (fieldName: string) => void;
25
+ unregisterField: (fieldName: string) => void;
8
26
  }
9
- declare const FormContext: react.Context<FormContextInterface>;
10
-
11
- export { FormContext };
27
+ export declare const FormContext: import("react").Context<FormContextInterface>;
28
+ export {};
@@ -1,10 +1,12 @@
1
1
  import { createContext } from "react";
2
+ // src/components/form/FormContext.ts
2
3
  const FormContext = createContext({
3
- getFieldMessage: () => null,
4
- messageTranslations: {},
5
- registerField: () => null,
6
- unregisterField: () => null
4
+ fieldErrors: {},
5
+ messages: [],
6
+ submissionId: 0,
7
+ formatMessage: (code) => code,
8
+ pending: false,
9
+ registerField: () => null,
10
+ unregisterField: () => null
7
11
  });
8
- export {
9
- FormContext
10
- };
12
+ export { FormContext };
@@ -1,12 +1,8 @@
1
- import * as react from 'react';
2
- import { ComponentProps } from 'react';
3
- import { Field } from '@base-ui/react/field';
4
-
1
+ import { Field } from "@base-ui/react/field";
2
+ import { ComponentProps } from "react";
5
3
  type ServerSideErrorProps = {
6
- name: string;
7
- messages?: Partial<Record<string, string>>;
8
- render?: ComponentProps<typeof Field.Error>["render"];
4
+ name: string;
5
+ render?: ComponentProps<typeof Field.Error>["render"];
9
6
  };
10
- declare const ServerSideError: ({ name, messages: fieldMessages, render, }: ServerSideErrorProps) => react.JSX.Element | null;
11
-
12
- export { ServerSideError as default };
7
+ declare const ServerSideError: ({ name, render }: ServerSideErrorProps) => import("react").JSX.Element[];
8
+ export { ServerSideError as default };
@@ -1,19 +1,15 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
3
2
  import { Field } from "@base-ui/react/field";
4
3
  import { use } from "react";
5
4
  import { FormContext } from "./FormContext.js";
6
- const ServerSideError = ({
7
- name,
8
- messages: fieldMessages = {},
9
- render
10
- }) => {
11
- const { getFieldMessage, messageTranslations: formMessages } = use(FormContext);
12
- const message = getFieldMessage(name);
13
- if (!message) return null;
14
- return /* @__PURE__ */ jsx(Field.Error, { match: true, render, children: fieldMessages[message] || formMessages[message] || message });
15
- };
16
- var ServerSideError_default = ServerSideError;
17
- export {
18
- ServerSideError_default as default
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}`));
19
14
  };
15
+ export { ServerSideError as default };
@@ -1,11 +1,7 @@
1
- export { default as BaseInput } from './BaseInput.js';
2
- export { default as BaseSwitch } from './BaseSwitch.js';
3
- export { default as BaseForm } from './BaseForm.js';
4
- export { default as BaseFormField } from './BaseFormField.js';
5
- import 'react';
6
- import '../elements/JustInput.js';
7
- import '@base-ui/react/use-render';
8
- import '@base-ui/react/switch';
9
- import '../elements/JustDiv.js';
10
- import '@base-ui/react/field';
11
- import 'zod';
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
+ import { DisplayedFormMessage, MessageFormatter } from "./FormContext.js";
7
+ export { BaseForm, BaseFormField, BaseInput, BaseSwitch, type DisplayedFormMessage, type MessageFormatter, useFormMessages };
@@ -1,10 +1,6 @@
1
- import { default as default2 } from "./BaseInput.js";
2
- import { default as default3 } from "./BaseSwitch.js";
3
- import { default as default4 } from "./BaseForm.js";
4
- import { default as default5 } from "./BaseFormField.js";
5
- export {
6
- default4 as BaseForm,
7
- default5 as BaseFormField,
8
- default2 as BaseInput,
9
- default3 as BaseSwitch
10
- };
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 from 'react';
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.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,2 +1,2 @@
1
- export { default as Container } from './Container.js';
2
- 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";
@@ -1,17 +1,13 @@
1
- import * as react from 'react';
2
- import { ComponentProps } from 'react';
3
- import JustAnchor from '../elements/JustAnchor.js';
4
- import JustButton from '../elements/JustButton.js';
5
- import '@base-ui/react/use-render';
6
-
1
+ import { ComponentProps } from "react";
2
+ import JustAnchor from "../elements/JustAnchor.js";
3
+ import JustButton from "../elements/JustButton.js";
7
4
  type PaginationProps = {
8
- totalItems: number;
9
- itemsPerPage: number;
10
- currentPage: number;
11
- queryParams: Record<string, unknown>;
12
- renderButton?: ComponentProps<typeof JustButton>["render"];
13
- renderLink?: ComponentProps<typeof JustAnchor>["render"];
5
+ totalItems: number;
6
+ itemsPerPage: number;
7
+ currentPage: number;
8
+ queryParams: Record<string, unknown>;
9
+ renderButton?: ComponentProps<typeof JustButton>["render"];
10
+ renderLink?: ComponentProps<typeof JustAnchor>["render"];
14
11
  };
15
- declare const Pagination: ({ totalItems, itemsPerPage, currentPage, queryParams, renderButton, renderLink, }: PaginationProps) => react.JSX.Element;
16
-
17
- export { Pagination as default };
12
+ declare const Pagination: ({ totalItems, itemsPerPage, currentPage, queryParams, renderButton, renderLink }: PaginationProps) => import("react").JSX.Element;
13
+ export { Pagination as default };