@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.
- package/MIGRATION.md +164 -0
- package/README.md +390 -0
- package/dist/components/button/BaseButton.d.ts +27 -11
- 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/AnimatedPopup.d.ts +3 -6
- package/dist/components/dialog/AnimatedPopup.js +6 -31
- package/dist/components/dialog/DialogBackdrop.d.ts +3 -6
- package/dist/components/dialog/DialogBackdrop.js +6 -22
- package/dist/components/dialog/DialogTitle.d.ts +3 -6
- package/dist/components/dialog/DialogTitle.js +6 -15
- package/dist/components/dialog/index.d.ts +4 -5
- package/dist/components/dialog/index.js +4 -8
- package/dist/components/elements/JustAnchor.d.ts +3 -6
- package/dist/components/elements/JustAnchor.js +8 -13
- package/dist/components/elements/JustButton.d.ts +3 -6
- package/dist/components/elements/JustButton.js +8 -13
- package/dist/components/elements/JustDiv.d.ts +3 -6
- package/dist/components/elements/JustDiv.js +8 -13
- package/dist/components/elements/JustInput.d.ts +3 -6
- package/dist/components/elements/JustInput.js +8 -13
- package/dist/components/form/BaseForm.d.ts +12 -15
- package/dist/components/form/BaseForm.js +72 -70
- package/dist/components/form/BaseFormField.d.ts +12 -19
- package/dist/components/form/BaseFormField.js +29 -24
- package/dist/components/form/BaseInput.d.ts +5 -9
- package/dist/components/form/BaseInput.js +20 -31
- package/dist/components/form/BaseSwitch.d.ts +6 -9
- package/dist/components/form/BaseSwitch.js +18 -51
- package/dist/components/form/ClientSideError.d.ts +9 -0
- package/dist/components/form/ClientSideError.js +39 -0
- package/dist/components/form/FieldRoot.d.ts +6 -9
- package/dist/components/form/FieldRoot.js +16 -18
- package/dist/components/form/FormContext.d.ts +26 -9
- package/dist/components/form/FormContext.js +9 -7
- package/dist/components/form/ServerSideError.d.ts +6 -10
- package/dist/components/form/ServerSideError.js +10 -14
- package/dist/components/form/index.d.ts +7 -11
- package/dist/components/form/index.js +6 -10
- package/dist/components/form/useFormMessages.d.ts +10 -0
- package/dist/components/form/useFormMessages.js +16 -0
- package/dist/components/layout/Container.d.ts +5 -8
- package/dist/components/layout/Container.js +8 -10
- package/dist/components/layout/index.d.ts +2 -2
- package/dist/components/layout/index.js +1 -4
- package/dist/components/page/Pagination.d.ts +11 -15
- package/dist/components/page/Pagination.js +60 -48
- package/dist/components/page/index.d.ts +2 -5
- package/dist/components/page/index.js +1 -4
- package/dist/components/table/Tdx.d.ts +5 -8
- package/dist/components/table/Tdx.js +13 -9
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/index.js +1 -4
- package/dist/hooks/useRipples.d.ts +2 -5
- package/dist/hooks/useRipples.js +46 -33
- package/dist/styles/ripple.module.css +1 -0
- package/dist/utils/cn.d.ts +6 -5
- package/dist/utils/cn.js +8 -6
- package/dist/utils/dirty-form.d.ts +1 -3
- package/dist/utils/dirty-form.js +24 -39
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +1 -4
- package/package.json +27 -24
- package/dist/components/button/PulseButton.d.ts +0 -8
- package/dist/components/button/PulseButton.js +0 -41
- package/dist/styles/ripple.module.d.ts +0 -2
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ComponentProps } from
|
|
3
|
-
import {
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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,
|
|
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 {
|
|
4
|
-
import { cn } from "
|
|
5
|
-
import
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
2
|
-
import
|
|
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
|
-
|
|
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 {
|
|
2
|
-
import
|
|
3
|
-
import { cn } from "../../utils/cn.js";
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
import "react";
|
|
4
3
|
import JustInput from "../elements/JustInput.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
2
|
-
import { ComponentProps, ReactNode } from
|
|
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
|
-
|
|
7
|
-
|
|
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 "
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
|
|
1
|
+
import { ReactNode } from "react";
|
|
4
2
|
type FieldRootProps = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
name: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
children: ReactNode;
|
|
8
6
|
};
|
|
9
|
-
declare const FieldRoot: ({ name, className, children
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
2
|
-
import { ComponentProps } from
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
render?: ComponentProps<typeof Field.Error>["render"];
|
|
4
|
+
name: string;
|
|
5
|
+
render?: ComponentProps<typeof Field.Error>["render"];
|
|
9
6
|
};
|
|
10
|
-
declare const ServerSideError: ({ name,
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
2
|
-
import { ComponentProps, ReactNode } from 'react';
|
|
3
|
-
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
2
|
type ContainerProps = ComponentProps<"div"> & {
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
className?: string;
|
|
4
|
+
children: ReactNode;
|
|
7
5
|
};
|
|
8
|
-
declare const Container: ({ className, children
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
2
|
-
|
|
1
|
+
import Container from "./Container.js";
|
|
2
|
+
export { Container };
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
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 };
|