@fldr/ui 0.3.8 → 0.3.10

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/README.md +67 -448
  2. package/ai/component-registry.json +27 -14
  3. package/ai/component-registry.md +3 -3
  4. package/dist/.build-complete +1 -1
  5. package/dist/blocks-source/auth-card/auth-card.test.tsx +20 -14
  6. package/dist/blocks-source/auth-card/auth-card.tsx +73 -55
  7. package/dist/blocks-source/file-table/file-table.tsx +197 -150
  8. package/dist/blocks-source/login-page/login-page.tsx +3 -1
  9. package/dist/blocks-source/share-dialog/share-dialog.test.tsx +9 -3
  10. package/dist/blocks-source/share-dialog/share-dialog.tsx +50 -35
  11. package/dist/blocks.d.ts +24 -5
  12. package/dist/blocks.js +250 -197
  13. package/dist/brands.d.ts +143 -0
  14. package/dist/brands.js +92 -0
  15. package/dist/{button-DzavLWXm.d.ts → button-CS82eT0x.d.ts} +1 -1
  16. package/dist/chunks/{checkbox-eifiwbw34xwsikvf.js → checkbox-d5epe4dl78bzy4f8.js} +8 -8
  17. package/dist/chunks/{dropdown-e5zk0ez21busnt0b.js → dropdown-oec4g1w9kbsjsg15.js} +1 -1
  18. package/dist/chunks/highlighter-kb7huz24pcziin6d.js +57 -0
  19. package/dist/chunks/{layer-dialog-m8qb0wzfg3k7406a.js → layer-dialog-ioa3r4ayemppsspx.js} +4 -3
  20. package/dist/chunks/{table-ngl1b5yc8mcur662.js → table-bdye068ekayq3u1n.js} +1 -1
  21. package/dist/chunks/table-n5yarooiknhc18ln.js +448 -0
  22. package/dist/chunks/{table-of-contents-gkjv9ck8etbz64ej.js → table-of-contents-d3pmkrk223umdz9h.js} +1 -1
  23. package/dist/code/server.js +1 -1
  24. package/dist/code.js +4 -131
  25. package/dist/components/banner.d.ts +1 -1
  26. package/dist/components/button.d.ts +2 -2
  27. package/dist/components/checkbox.d.ts +1 -1
  28. package/dist/components/checkbox.js +1 -1
  29. package/dist/components/dropdown.js +1 -1
  30. package/dist/components/input-group.d.ts +2 -1
  31. package/dist/components/input.d.ts +2 -2
  32. package/dist/components/layer-dialog.js +1 -1
  33. package/dist/components/link.d.ts +2 -67
  34. package/dist/components/sidebar.d.ts +2 -1
  35. package/dist/components/table-of-contents.js +1 -1
  36. package/dist/components/table.d.ts +1 -1
  37. package/dist/components/table.js +1 -1
  38. package/dist/components/toast.d.ts +1 -1
  39. package/dist/components/toolbar.d.ts +1 -1
  40. package/dist/form.d.ts +207 -0
  41. package/dist/form.js +317 -0
  42. package/dist/hotkeys.d.ts +135 -0
  43. package/dist/hotkeys.js +203 -0
  44. package/dist/index-9LwQy84o.d.ts +1 -0
  45. package/dist/index-B7iG0qDU.d.ts +1 -0
  46. package/dist/{index-B6JNUfG9.d.ts → index-BMXHK-3k.d.ts} +2 -2
  47. package/dist/{index-B6Wo_iiN.d.ts → index-B_ug9XY7.d.ts} +1 -1
  48. package/dist/{index-RP_rt8vB.d.ts → index-Bh9kuAvN.d.ts} +1 -1
  49. package/dist/{index-DjSGDESy.d.ts → index-CAUjUp2G.d.ts} +1 -1
  50. package/dist/{index-NnHba-T1.d.ts → index-DK28YxxP.d.ts} +2 -2
  51. package/dist/{index-aahL-0Zw.d.ts → index-DOVlARA6.d.ts} +2 -2
  52. package/dist/index-DTj6M6kA.d.ts +1 -0
  53. package/dist/index.d.ts +14 -12
  54. package/dist/index.js +5 -6
  55. package/dist/{input-group-8gEtPiKw.d.ts → input-group-Swzit45o.d.ts} +1 -1
  56. package/dist/link-CoVXE5W2.d.ts +68 -0
  57. package/dist/query.d.ts +156 -0
  58. package/dist/query.js +204 -0
  59. package/dist/router.d.ts +95 -0
  60. package/dist/router.js +146 -0
  61. package/dist/skeleton.d.ts +3 -0
  62. package/dist/skeleton.js +4 -0
  63. package/dist/styles/kumo-binding.css +36 -0
  64. package/dist/styles/kumo-standalone.css +1 -1
  65. package/dist/styles/theme-fldr.css +18 -18
  66. package/dist/table.d.ts +245 -0
  67. package/dist/table.js +3 -0
  68. package/dist/theming.d.ts +4 -4
  69. package/dist/theming.js +2 -2
  70. package/package.json +46 -1
  71. package/dist/chunks/highlighter-mouttug0tu8xg1i8.js +0 -1364
  72. package/dist/index-DL1-uSuH.d.ts +0 -1
  73. /package/dist/{index-BkTAB4wj.d.ts → sidebar-BkTAB4wj.d.ts} +0 -0
@@ -1,67 +1,2 @@
1
- import { t as LinkComponentProps } from "../link-provider-tz-NJp9x.js";
2
- import { SVGProps } from "react";
3
- import { useRender } from "@base-ui/react/use-render";
4
- //#region src/components/link/link.d.ts
5
- /** Link variant definitions mapping variant names to their Tailwind classes. */
6
- export declare const KUMO_LINK_VARIANTS: {
7
- readonly variant: {
8
- readonly inline: {
9
- readonly classes: "text-kumo-link underline underline-offset-[0.15em] decoration-[0.0625em] link-current transition-colors";
10
- readonly description: "Inline text link that flows with content";
11
- };
12
- readonly current: {
13
- readonly classes: "text-current underline underline-offset-[0.15em] decoration-[0.0625em] link-current transition-colors";
14
- readonly description: "Link that inherits color from parent text";
15
- };
16
- readonly plain: {
17
- readonly classes: "text-kumo-link hover:text-kumo-link/70 transition-colors";
18
- readonly description: "Link without underline decoration";
19
- };
20
- };
21
- };
22
- export declare const KUMO_LINK_DEFAULT_VARIANTS: {
23
- readonly variant: "inline";
24
- };
25
- export type KumoLinkVariant = keyof typeof KUMO_LINK_VARIANTS.variant;
26
- export interface KumoLinkVariantsProps {
27
- /**
28
- * Visual style of the link.
29
- * - `"inline"` — Inline text link that flows with content
30
- * - `"current"` — Link that inherits color from parent text
31
- * - `"plain"` — Link without underline decoration
32
- * @default "inline"
33
- */
34
- variant?: KumoLinkVariant;
35
- }
36
- export declare function linkVariants({ variant }?: KumoLinkVariantsProps): string;
37
- /**
38
- * Link component props.
39
- *
40
- * Use `href` for the link destination. For framework-specific routing, use the
41
- * `render` prop or configure a `LinkProvider` at the app root.
42
- *
43
- * @example Internal link
44
- * ```tsx
45
- * <Link href="/docs">Learn more</Link>
46
- * ```
47
- *
48
- * @example External link
49
- * ```tsx
50
- * <Link href="https://cloudflare.com" target="_blank" rel="noopener noreferrer">
51
- * Visit Cloudflare <Link.ExternalIcon />
52
- * </Link>
53
- * ```
54
- *
55
- * @example Composition with render prop
56
- * ```tsx
57
- * <Link render={<RouterLink to="/dashboard" />}>Dashboard</Link>
58
- * ```
59
- */
60
- export type LinkProps = useRender.ComponentProps<"a"> & LinkComponentProps & KumoLinkVariantsProps;
61
- export declare const Link: import("react").ForwardRefExoticComponent<Omit<LinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>> & {
62
- ExternalIcon: {
63
- (props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
64
- displayName: string;
65
- };
66
- };
67
- //#endregion
1
+ import { a as Link, i as KumoLinkVariantsProps, n as KUMO_LINK_VARIANTS, o as LinkProps, r as KumoLinkVariant, s as linkVariants, t as KUMO_LINK_DEFAULT_VARIANTS } from "../link-CoVXE5W2.js";
2
+ export { KUMO_LINK_DEFAULT_VARIANTS, KUMO_LINK_VARIANTS, KumoLinkVariant, KumoLinkVariantsProps, Link, LinkProps, linkVariants };
@@ -1,2 +1,3 @@
1
- import { A as SidebarProviderProps, B as SidebarSlidingViewProps, C as SidebarMenuItem, D as SidebarMenuSubButtonProps, E as SidebarMenuSubButton, F as SidebarScrollAlign, G as SidebarVariant, H as SidebarSlidingViewsProps, I as SidebarScrollToItemOptions, K as useSidebar, L as SidebarSeparator, M as SidebarResizeHandle, N as SidebarRoot, O as SidebarMenuSubItem, P as SidebarRootProps, R as SidebarSide, S as SidebarMenuChevron, T as SidebarMenuSub, U as SidebarState, V as SidebarSlidingViews, W as SidebarTrigger, _ as SidebarMenu, a as SidebarCollapsible, b as SidebarMenuButtonProps, c as SidebarCollapsibleTrigger, d as SidebarContextValue, f as SidebarFooter, g as SidebarLoading, h as SidebarHeader, i as Sidebar, j as SidebarRail, k as SidebarProvider, l as SidebarCollapsibleTriggerProps, m as SidebarGroupLabel, n as KUMO_SIDEBAR_STYLING, o as SidebarCollapsibleContent, p as SidebarGroup, r as KUMO_SIDEBAR_VARIANTS, s as SidebarCollapsibleProps, t as KUMO_SIDEBAR_DEFAULT_VARIANTS, u as SidebarContent, v as SidebarMenuBadge, w as SidebarMenuItemProps, x as SidebarMenuButtonSize, y as SidebarMenuButton, z as SidebarSlidingView } from "../index-BkTAB4wj.js";
1
+ import { A as SidebarProviderProps, B as SidebarSlidingViewProps, C as SidebarMenuItem, D as SidebarMenuSubButtonProps, E as SidebarMenuSubButton, F as SidebarScrollAlign, G as SidebarVariant, H as SidebarSlidingViewsProps, I as SidebarScrollToItemOptions, K as useSidebar, L as SidebarSeparator, M as SidebarResizeHandle, N as SidebarRoot, O as SidebarMenuSubItem, P as SidebarRootProps, R as SidebarSide, S as SidebarMenuChevron, T as SidebarMenuSub, U as SidebarState, V as SidebarSlidingViews, W as SidebarTrigger, _ as SidebarMenu, a as SidebarCollapsible, b as SidebarMenuButtonProps, c as SidebarCollapsibleTrigger, d as SidebarContextValue, f as SidebarFooter, g as SidebarLoading, h as SidebarHeader, i as Sidebar, j as SidebarRail, k as SidebarProvider, l as SidebarCollapsibleTriggerProps, m as SidebarGroupLabel, n as KUMO_SIDEBAR_STYLING, o as SidebarCollapsibleContent, p as SidebarGroup, r as KUMO_SIDEBAR_VARIANTS, s as SidebarCollapsibleProps, t as KUMO_SIDEBAR_DEFAULT_VARIANTS, u as SidebarContent, v as SidebarMenuBadge, w as SidebarMenuItemProps, x as SidebarMenuButtonSize, y as SidebarMenuButton, z as SidebarSlidingView } from "../sidebar-BkTAB4wj.js";
2
+ import "../index-DTj6M6kA.js";
2
3
  export { KUMO_SIDEBAR_DEFAULT_VARIANTS, KUMO_SIDEBAR_STYLING, KUMO_SIDEBAR_VARIANTS, Sidebar, SidebarCollapsible, type SidebarCollapsible as SidebarCollapsibleType, SidebarCollapsibleContent, type SidebarCollapsibleProps, SidebarCollapsibleTrigger, type SidebarCollapsibleTriggerProps, SidebarContent, type SidebarContextValue, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarHeader, SidebarLoading, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, SidebarMenuChevron, SidebarMenuItem, type SidebarMenuItemProps, SidebarMenuSub, SidebarMenuSubButton, type SidebarMenuSubButtonProps, SidebarMenuSubItem, SidebarProvider, type SidebarProviderProps, SidebarRail, SidebarResizeHandle, SidebarRoot, type SidebarRootProps, type SidebarScrollAlign, type SidebarScrollToItemOptions, SidebarSeparator, type SidebarSide, SidebarSlidingView, type SidebarSlidingViewProps, SidebarSlidingViews, type SidebarSlidingViewsProps, type SidebarState, SidebarTrigger, type SidebarVariant, useSidebar };
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import { i as TableOfContents, n as KUMO_TABLE_OF_CONTENTS_DEFAULT_VARIANTS, r as KUMO_TABLE_OF_CONTENTS_VARIANTS, t as useTableOfContentsActiveId } from "../chunks/table-of-contents-gkjv9ck8etbz64ej.js";
2
+ import { i as TableOfContents, n as KUMO_TABLE_OF_CONTENTS_DEFAULT_VARIANTS, r as KUMO_TABLE_OF_CONTENTS_VARIANTS, t as useTableOfContentsActiveId } from "../chunks/table-of-contents-d3pmkrk223umdz9h.js";
3
3
  export { KUMO_TABLE_OF_CONTENTS_DEFAULT_VARIANTS, KUMO_TABLE_OF_CONTENTS_VARIANTS, TableOfContents, useTableOfContentsActiveId };
@@ -1,2 +1,2 @@
1
- import { a as Table, i as KumoTableRowVariant, n as KUMO_TABLE_VARIANTS, r as KumoTableLayout, t as KUMO_TABLE_DEFAULT_VARIANTS } from "../index-RP_rt8vB.js";
1
+ import { a as Table, i as KumoTableRowVariant, n as KUMO_TABLE_VARIANTS, r as KumoTableLayout, t as KUMO_TABLE_DEFAULT_VARIANTS } from "../index-Bh9kuAvN.js";
2
2
  export { KUMO_TABLE_DEFAULT_VARIANTS, KUMO_TABLE_VARIANTS, type KumoTableLayout, type KumoTableRowVariant, Table };
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import { n as KUMO_TABLE_VARIANTS, r as Table, t as KUMO_TABLE_DEFAULT_VARIANTS } from "../chunks/table-ngl1b5yc8mcur662.js";
2
+ import { n as KUMO_TABLE_VARIANTS, r as Table, t as KUMO_TABLE_DEFAULT_VARIANTS } from "../chunks/table-bdye068ekayq3u1n.js";
3
3
  export { KUMO_TABLE_DEFAULT_VARIANTS, KUMO_TABLE_VARIANTS, Table };
@@ -1,2 +1,2 @@
1
- import { a as Toasty, i as ToastProvider, n as KumoToastManagerAddOptions, o as createKumoToastManager, r as KumoToastOptions, s as useKumoToastManager, t as Toast } from "../index-B6JNUfG9.js";
1
+ import { a as Toasty, i as ToastProvider, n as KumoToastManagerAddOptions, o as createKumoToastManager, r as KumoToastOptions, s as useKumoToastManager, t as Toast } from "../index-BMXHK-3k.js";
2
2
  export { type KumoToastManagerAddOptions, type KumoToastOptions, Toast, ToastProvider, Toasty, createKumoToastManager, useKumoToastManager };
@@ -1,2 +1,2 @@
1
- import { a as ToolbarInputGroupProps, c as ToolbarProps, i as ToolbarButtonProps, l as ToolbarSize, n as KUMO_TOOLBAR_VARIANTS, o as ToolbarInputProps, r as Toolbar, s as ToolbarLinkProps, t as KUMO_TOOLBAR_DEFAULT_VARIANTS } from "../index-aahL-0Zw.js";
1
+ import { a as ToolbarInputGroupProps, c as ToolbarProps, i as ToolbarButtonProps, l as ToolbarSize, n as KUMO_TOOLBAR_VARIANTS, o as ToolbarInputProps, r as Toolbar, s as ToolbarLinkProps, t as KUMO_TOOLBAR_DEFAULT_VARIANTS } from "../index-DOVlARA6.js";
2
2
  export { KUMO_TOOLBAR_DEFAULT_VARIANTS, KUMO_TOOLBAR_VARIANTS, Toolbar, type ToolbarButtonProps, type ToolbarInputGroupProps, type ToolbarInputProps, type ToolbarLinkProps, type ToolbarProps, type ToolbarSize };
package/dist/form.d.ts ADDED
@@ -0,0 +1,207 @@
1
+ import { n as ButtonProps } from "./button-CS82eT0x.js";
2
+ import "./index-9LwQy84o.js";
3
+ import { o as CheckboxProps } from "./index-CAUjUp2G.js";
4
+ import { n as InputProps } from "./input-BeWEb-jD.js";
5
+ import { i as InputAreaProps } from "./index-B_ug9XY7.js";
6
+ import { u as RadioGroupProps } from "./index-CU_lnxg7.js";
7
+ import { t as Select } from "./index-DwNMa4LN.js";
8
+ import { l as SwitchProps } from "./index-AMEc1MEg.js";
9
+ import { ComponentProps, ReactNode } from "react";
10
+ //#region src/form/form.d.ts
11
+ export declare const fieldContext: import("react").Context<import("@tanstack/react-form").AnyFieldApi>, formContext: import("react").Context<import("@tanstack/react-form").AnyFormApi>, useFieldContext: <TData>() => import("@tanstack/react-form").FieldApi<any, string, TData, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>, useFormContext: () => import("@tanstack/react-form").ReactFormExtendedApi<Record<string, never>, any, any, any, any, any, any, any, any, any, any, any>;
12
+ /** Returns the first readable message from TanStack Form errors (strings, Standard Schema issues, or nested arrays). */
13
+ export declare function firstErrorMessage(errors: readonly unknown[]): string | undefined;
14
+ type Bound<P, K extends PropertyKey> = Omit<P, K | "name" | "error" | "defaultValue">;
15
+ export type TextFieldProps = Bound<InputProps, "value" | "onChange" | "onBlur">;
16
+ /**
17
+ * Text input bound to the surrounding `form.AppField`. Pass `type` / `autoComplete` through;
18
+ * `className` applies to the input.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * <form.AppField name="email">
23
+ * {(field) => <field.TextField label="Email" type="email" autoComplete="email" />}
24
+ * </form.AppField>
25
+ * ```
26
+ */
27
+ export declare function TextField(props: TextFieldProps): import("react/jsx-runtime").JSX.Element;
28
+ export type NumberFieldProps = Bound<InputProps, "value" | "onChange" | "onBlur" | "type">;
29
+ /** Number input; an empty input stores `undefined`. */
30
+ export declare function NumberField(props: NumberFieldProps): import("react/jsx-runtime").JSX.Element;
31
+ export type TextareaFieldProps = Bound<InputAreaProps, "value" | "onChange" | "onValueChange" | "onBlur">;
32
+ /** Multi-line text input bound to the surrounding field. Give it a `label` (or `description`) so the error can appear without remounting the textarea. */
33
+ export declare function TextareaField(props: TextareaFieldProps): import("react/jsx-runtime").JSX.Element;
34
+ export type SelectFieldProps = Bound<ComponentProps<typeof Select<string>>, "value" | "onValueChange" | "multiple">;
35
+ /**
36
+ * Select bound to a string field. Pass `items` (`{ key: "Label" }`) or `Select.Option` children.
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * <form.AppField name="role">
41
+ * {(field) => <field.SelectField label="Role" items={{ viewer: "Viewer", editor: "Editor" }} />}
42
+ * </form.AppField>
43
+ * ```
44
+ */
45
+ export declare function SelectField({ onOpenChange, ...props }: SelectFieldProps): import("react/jsx-runtime").JSX.Element;
46
+ export type CheckboxFieldProps = Omit<CheckboxProps, "checked" | "onCheckedChange" | "name"> & {
47
+ description?: ReactNode;
48
+ };
49
+ /** Checkbox bound to a boolean field. */
50
+ export declare function CheckboxField({ description, ...props }: CheckboxFieldProps): import("react/jsx-runtime").JSX.Element;
51
+ export type SwitchFieldProps = Omit<SwitchProps, "checked" | "onCheckedChange" | "name"> & {
52
+ description?: ReactNode;
53
+ };
54
+ /** Switch bound to a boolean field. */
55
+ export declare function SwitchField({ description, ...props }: SwitchFieldProps): import("react/jsx-runtime").JSX.Element;
56
+ export interface RadioFieldItem {
57
+ value: string;
58
+ label: ReactNode;
59
+ description?: ReactNode;
60
+ disabled?: boolean;
61
+ }
62
+ export type RadioFieldProps = Omit<RadioGroupProps<string>, "value" | "defaultValue" | "onValueChange" | "error" | "name" | "children"> & {
63
+ /** Options; use `children` (`Radio.Item`) for full control. */
64
+ items?: RadioFieldItem[];
65
+ children?: ReactNode;
66
+ };
67
+ /** Radio group bound to a string field. */
68
+ export declare function RadioField({ items, children, ...props }: RadioFieldProps): import("react/jsx-runtime").JSX.Element;
69
+ export type FormProps = Omit<ComponentProps<"form">, "onSubmit">;
70
+ /**
71
+ * `<form>` that prevents the native submit and calls `form.handleSubmit()`.
72
+ * Render inside `form.AppForm`, or use `form.Form`.
73
+ */
74
+ export declare function Form({ noValidate, ...props }: FormProps): import("react/jsx-runtime").JSX.Element;
75
+ export type SubmitButtonProps = Pick<ButtonProps, "variant" | "size" | "icon" | "className" | "disabled" | "loading" | "children">;
76
+ /** Submit button; disabled while the form is invalid or submitting, shows a spinner while submitting. */
77
+ export declare function SubmitButton({ variant, disabled, loading, ...props }: SubmitButtonProps): import("react/jsx-runtime").JSX.Element;
78
+ export type ResetButtonProps = SubmitButtonProps;
79
+ /** Resets the form to its default values. */
80
+ export declare function ResetButton({ variant, ...props }: ResetButtonProps): import("react/jsx-runtime").JSX.Element;
81
+ export interface FormErrorBannerProps {
82
+ /** Overrides form-level validation errors, e.g. a server error. */
83
+ error?: ReactNode;
84
+ className?: string;
85
+ }
86
+ /** Shows `error` or the first form-level validation error in an error Banner. */
87
+ export declare function FormErrorBanner({ error, className }: FormErrorBannerProps): import("react/jsx-runtime").JSX.Element | null;
88
+ /**
89
+ * fldr form hook: TanStack Form's `useForm` pre-wired with fldr field and form components.
90
+ * Validators accept functions or any Standard Schema (e.g. zod v4) directly.
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * const form = useAppForm({
95
+ * defaultValues: { email: "" },
96
+ * validators: { onChange: z.object({ email: z.email() }) },
97
+ * onSubmit: ({ value }) => save(value),
98
+ * });
99
+ * return (
100
+ * <form.AppForm>
101
+ * <form.Form className="flex flex-col gap-3">
102
+ * <form.AppField name="email">{(f) => <f.TextField label="Email" />}</form.AppField>
103
+ * <form.SubmitButton>Save</form.SubmitButton>
104
+ * </form.Form>
105
+ * </form.AppForm>
106
+ * );
107
+ * ```
108
+ */
109
+ export declare const useAppForm: <TFormData, TOnMount extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChange extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TSubmitMeta>(props: import("@tanstack/react-form").FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
110
+ readonly TextField: typeof TextField;
111
+ readonly NumberField: typeof NumberField;
112
+ readonly TextareaField: typeof TextareaField;
113
+ readonly SelectField: typeof SelectField;
114
+ readonly CheckboxField: typeof CheckboxField;
115
+ readonly SwitchField: typeof SwitchField;
116
+ readonly RadioField: typeof RadioField;
117
+ }, {
118
+ readonly Form: typeof Form;
119
+ readonly SubmitButton: typeof SubmitButton;
120
+ readonly ResetButton: typeof ResetButton;
121
+ readonly FormErrorBanner: typeof FormErrorBanner;
122
+ }>, withForm: <TFormData, TOnMount extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChange extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TSubmitMeta, TRenderProps extends object = {}>({ render, props }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
123
+ readonly TextField: typeof TextField;
124
+ readonly NumberField: typeof NumberField;
125
+ readonly TextareaField: typeof TextareaField;
126
+ readonly SelectField: typeof SelectField;
127
+ readonly CheckboxField: typeof CheckboxField;
128
+ readonly SwitchField: typeof SwitchField;
129
+ readonly RadioField: typeof RadioField;
130
+ }, {
131
+ readonly Form: typeof Form;
132
+ readonly SubmitButton: typeof SubmitButton;
133
+ readonly ResetButton: typeof ResetButton;
134
+ readonly FormErrorBanner: typeof FormErrorBanner;
135
+ }, TRenderProps>) => import("react").FunctionComponent<import("react").PropsWithChildren<NoInfer<[unknown] extends [TRenderProps] ? any : TRenderProps> & {
136
+ form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
137
+ readonly TextField: typeof TextField;
138
+ readonly NumberField: typeof NumberField;
139
+ readonly TextareaField: typeof TextareaField;
140
+ readonly SelectField: typeof SelectField;
141
+ readonly CheckboxField: typeof CheckboxField;
142
+ readonly SwitchField: typeof SwitchField;
143
+ readonly RadioField: typeof RadioField;
144
+ }, {
145
+ readonly Form: typeof Form;
146
+ readonly SubmitButton: typeof SubmitButton;
147
+ readonly ResetButton: typeof ResetButton;
148
+ readonly FormErrorBanner: typeof FormErrorBanner;
149
+ }>;
150
+ }>>, withFieldGroup: <TFieldGroupData, TSubmitMeta, TRenderProps extends object = {}>({ render, props, defaultValues }: import("@tanstack/react-form").WithFieldGroupProps<TFieldGroupData, {
151
+ readonly TextField: typeof TextField;
152
+ readonly NumberField: typeof NumberField;
153
+ readonly TextareaField: typeof TextareaField;
154
+ readonly SelectField: typeof SelectField;
155
+ readonly CheckboxField: typeof CheckboxField;
156
+ readonly SwitchField: typeof SwitchField;
157
+ readonly RadioField: typeof RadioField;
158
+ }, {
159
+ readonly Form: typeof Form;
160
+ readonly SubmitButton: typeof SubmitButton;
161
+ readonly ResetButton: typeof ResetButton;
162
+ readonly FormErrorBanner: typeof FormErrorBanner;
163
+ }, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/react-form").DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import("@tanstack/react-form").FieldsMap<TFormData, TFieldGroupData>, TOnMount extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChange extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnChangeAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnBlur extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnBlurAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnSubmit extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnSubmitAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnDynamic extends import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined, TOnDynamicAsync extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TOnServer extends import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData> | undefined, TFormSubmitMeta>(params: import("react").PropsWithChildren<NoInfer<TRenderProps> & {
164
+ form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
165
+ readonly TextField: typeof TextField;
166
+ readonly NumberField: typeof NumberField;
167
+ readonly TextareaField: typeof TextareaField;
168
+ readonly SelectField: typeof SelectField;
169
+ readonly CheckboxField: typeof CheckboxField;
170
+ readonly SwitchField: typeof SwitchField;
171
+ readonly RadioField: typeof RadioField;
172
+ }, {
173
+ readonly Form: typeof Form;
174
+ readonly SubmitButton: typeof SubmitButton;
175
+ readonly ResetButton: typeof ResetButton;
176
+ readonly FormErrorBanner: typeof FormErrorBanner;
177
+ }> | import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/react-form").FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
178
+ readonly TextField: typeof TextField;
179
+ readonly NumberField: typeof NumberField;
180
+ readonly TextareaField: typeof TextareaField;
181
+ readonly SelectField: typeof SelectField;
182
+ readonly CheckboxField: typeof CheckboxField;
183
+ readonly SwitchField: typeof SwitchField;
184
+ readonly RadioField: typeof RadioField;
185
+ }, {
186
+ readonly Form: typeof Form;
187
+ readonly SubmitButton: typeof SubmitButton;
188
+ readonly ResetButton: typeof ResetButton;
189
+ readonly FormErrorBanner: typeof FormErrorBanner;
190
+ }>;
191
+ fields: TFields;
192
+ }>) => ReturnType<import("react").FunctionComponent>;
193
+ /** Field-level validator: fails on empty / whitespace-only strings, `false` or nullish values. */
194
+ export declare function required(message?: string): ({ value }: {
195
+ value: unknown;
196
+ }) => string | undefined;
197
+ /** Field-level validator: fails when a non-empty string is not an email address. Combine with `required` for mandatory fields. */
198
+ export declare function email(message?: string): ({ value }: {
199
+ value: string;
200
+ }) => string | undefined;
201
+ /** Runs validators in order and returns the first error. */
202
+ export declare function compose<T>(...validators: Array<(arg: {
203
+ value: T;
204
+ }) => string | undefined>): (arg: {
205
+ value: T;
206
+ }) => string | undefined;
207
+ //#endregion
package/dist/form.js ADDED
@@ -0,0 +1,317 @@
1
+ "use client";
2
+ import { t as cn } from "./chunks/vendor-styling-gs32v7xt5znc8kg0.js";
3
+ import { t as Button } from "./chunks/button-hzvowfkbathmx8yg.js";
4
+ import { t as Banner } from "./chunks/banner-mo1xl9ww734kgsqh.js";
5
+ import { t as Checkbox } from "./chunks/checkbox-d5epe4dl78bzy4f8.js";
6
+ import { t as Field } from "./chunks/field-fowmq5smvp17pnqe.js";
7
+ import { n as KUMO_INPUT_VARIANTS, t as Input } from "./chunks/input-kfi46426y22ocoo4.js";
8
+ import { t as InputArea } from "./chunks/input-m2tfec2viezoz9hh.js";
9
+ import { t as Select } from "./chunks/select-h2pejw38n5z3l59r.js";
10
+ import { r as Switch } from "./chunks/switch-nc8thi7ogd51m3gi.js";
11
+ import { r as Radio } from "./chunks/radio-nf717i5ypsga9zdh.js";
12
+ import { useId } from "react";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ import { WarningCircleIcon } from "@phosphor-icons/react";
15
+ import { createFormHook, createFormHookContexts, useSelector } from "@tanstack/react-form";
16
+ //#region src/form/form.tsx
17
+ const { fieldContext, formContext, useFieldContext, useFormContext } = createFormHookContexts();
18
+ /** Returns the first readable message from TanStack Form errors (strings, Standard Schema issues, or nested arrays). */
19
+ function firstErrorMessage(errors) {
20
+ for (const error of errors) {
21
+ if (typeof error === "string" && error) return error;
22
+ if (Array.isArray(error)) {
23
+ const nested = firstErrorMessage(error);
24
+ if (nested) return nested;
25
+ } else if (error && typeof error === "object" && "message" in error && typeof error.message === "string") return error.message;
26
+ }
27
+ }
28
+ /** Field error message, shown only once the field was blurred or the form was submitted. */
29
+ function useFieldError() {
30
+ const field = useFieldContext();
31
+ const submitted = useSelector(field.form.store, (s) => s.submissionAttempts > 0);
32
+ const { isBlurred, errors } = field.state.meta;
33
+ return isBlurred || submitted ? firstErrorMessage(errors) : void 0;
34
+ }
35
+ /** Description / error line for controls without a built-in Field wrapper. */
36
+ function FieldMessage({ id, error, description }) {
37
+ if (!error && !description) return null;
38
+ return /* @__PURE__ */ jsx("p", {
39
+ id,
40
+ className: cn("text-sm leading-snug", error ? "text-kumo-danger" : "text-kumo-subtle"),
41
+ children: error ?? description
42
+ });
43
+ }
44
+ /**
45
+ * Input wrapped in a Field that is always rendered, so toggling the error
46
+ * never remounts the input (Kumo's Input only wraps itself when it has a
47
+ * label, description or error).
48
+ */
49
+ function BoundInput({ label, labelTooltip, description, className, error, ...props }) {
50
+ return /* @__PURE__ */ jsx(Field, {
51
+ label,
52
+ labelTooltip,
53
+ required: props.required,
54
+ description,
55
+ error: error ? {
56
+ message: error,
57
+ match: true
58
+ } : void 0,
59
+ children: /* @__PURE__ */ jsx(Input, {
60
+ ...props,
61
+ className: cn(error && KUMO_INPUT_VARIANTS.variant.error.classes, className),
62
+ "aria-invalid": error ? true : void 0
63
+ })
64
+ });
65
+ }
66
+ /**
67
+ * Text input bound to the surrounding `form.AppField`. Pass `type` / `autoComplete` through;
68
+ * `className` applies to the input.
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * <form.AppField name="email">
73
+ * {(field) => <field.TextField label="Email" type="email" autoComplete="email" />}
74
+ * </form.AppField>
75
+ * ```
76
+ */
77
+ function TextField(props) {
78
+ const field = useFieldContext();
79
+ return /* @__PURE__ */ jsx(BoundInput, {
80
+ ...props,
81
+ name: field.name,
82
+ value: field.state.value ?? "",
83
+ onChange: (event) => field.handleChange(event.target.value),
84
+ onBlur: field.handleBlur,
85
+ error: useFieldError()
86
+ });
87
+ }
88
+ /** Number input; an empty input stores `undefined`. */
89
+ function NumberField(props) {
90
+ const field = useFieldContext();
91
+ return /* @__PURE__ */ jsx(BoundInput, {
92
+ inputMode: "decimal",
93
+ ...props,
94
+ type: "number",
95
+ name: field.name,
96
+ value: field.state.value ?? "",
97
+ onChange: (event) => field.handleChange(event.target.value === "" ? void 0 : event.target.valueAsNumber),
98
+ onBlur: field.handleBlur,
99
+ error: useFieldError()
100
+ });
101
+ }
102
+ /** Multi-line text input bound to the surrounding field. Give it a `label` (or `description`) so the error can appear without remounting the textarea. */
103
+ function TextareaField(props) {
104
+ const field = useFieldContext();
105
+ const error = useFieldError();
106
+ return /* @__PURE__ */ jsx(InputArea, {
107
+ ...props,
108
+ name: field.name,
109
+ value: field.state.value ?? "",
110
+ onValueChange: field.handleChange,
111
+ onBlur: field.handleBlur,
112
+ error,
113
+ "aria-invalid": error ? true : void 0
114
+ });
115
+ }
116
+ /**
117
+ * Select bound to a string field. Pass `items` (`{ key: "Label" }`) or `Select.Option` children.
118
+ *
119
+ * @example
120
+ * ```tsx
121
+ * <form.AppField name="role">
122
+ * {(field) => <field.SelectField label="Role" items={{ viewer: "Viewer", editor: "Editor" }} />}
123
+ * </form.AppField>
124
+ * ```
125
+ */
126
+ function SelectField({ onOpenChange, ...props }) {
127
+ const field = useFieldContext();
128
+ const error = useFieldError();
129
+ return /* @__PURE__ */ jsx(Select, {
130
+ ...props,
131
+ name: field.name,
132
+ value: field.state.value,
133
+ onValueChange: (value) => field.handleChange(value ?? ""),
134
+ onOpenChange: (open, details) => {
135
+ if (!open) field.handleBlur();
136
+ onOpenChange?.(open, details);
137
+ },
138
+ error
139
+ });
140
+ }
141
+ /** Checkbox bound to a boolean field. */
142
+ function CheckboxField({ description, ...props }) {
143
+ const field = useFieldContext();
144
+ const error = useFieldError();
145
+ const id = useId();
146
+ return /* @__PURE__ */ jsxs("div", {
147
+ className: "flex flex-col gap-1",
148
+ onBlur: field.handleBlur,
149
+ children: [/* @__PURE__ */ jsx(Checkbox, {
150
+ variant: error ? "error" : props.variant,
151
+ ...props,
152
+ name: field.name,
153
+ checked: field.state.value ?? false,
154
+ onCheckedChange: (checked) => field.handleChange(checked),
155
+ "aria-invalid": error ? true : void 0,
156
+ "aria-describedby": error || description ? id : void 0
157
+ }), /* @__PURE__ */ jsx(FieldMessage, {
158
+ id,
159
+ error,
160
+ description
161
+ })]
162
+ });
163
+ }
164
+ /** Switch bound to a boolean field. */
165
+ function SwitchField({ description, ...props }) {
166
+ const field = useFieldContext();
167
+ const error = useFieldError();
168
+ const id = useId();
169
+ return /* @__PURE__ */ jsxs("div", {
170
+ className: "flex flex-col gap-1",
171
+ children: [/* @__PURE__ */ jsx(Switch, {
172
+ ...props,
173
+ name: field.name,
174
+ checked: field.state.value ?? false,
175
+ onCheckedChange: field.handleChange,
176
+ onBlur: field.handleBlur,
177
+ "aria-invalid": error ? true : void 0,
178
+ "aria-describedby": error || description ? id : void 0
179
+ }), /* @__PURE__ */ jsx(FieldMessage, {
180
+ id,
181
+ error,
182
+ description
183
+ })]
184
+ });
185
+ }
186
+ /** Radio group bound to a string field. */
187
+ function RadioField({ items, children, ...props }) {
188
+ const field = useFieldContext();
189
+ const error = useFieldError();
190
+ return /* @__PURE__ */ jsx("div", {
191
+ className: "contents",
192
+ onBlur: field.handleBlur,
193
+ children: /* @__PURE__ */ jsx(Radio, {
194
+ ...props,
195
+ name: field.name,
196
+ value: field.state.value,
197
+ onValueChange: (value) => field.handleChange(value),
198
+ error,
199
+ children: children ?? items?.map((item) => /* @__PURE__ */ jsx(Radio.Item, { ...item }, item.value))
200
+ })
201
+ });
202
+ }
203
+ /**
204
+ * `<form>` that prevents the native submit and calls `form.handleSubmit()`.
205
+ * Render inside `form.AppForm`, or use `form.Form`.
206
+ */
207
+ function Form({ noValidate = true, ...props }) {
208
+ const form = useFormContext();
209
+ return /* @__PURE__ */ jsx("form", {
210
+ noValidate,
211
+ ...props,
212
+ onSubmit: (event) => {
213
+ event.preventDefault();
214
+ event.stopPropagation();
215
+ form.handleSubmit();
216
+ }
217
+ });
218
+ }
219
+ /** Submit button; disabled while the form is invalid or submitting, shows a spinner while submitting. */
220
+ function SubmitButton({ variant = "primary", disabled, loading, ...props }) {
221
+ const form = useFormContext();
222
+ const [canSubmit, isSubmitting] = useSelector(form.store, (s) => [s.canSubmit, s.isSubmitting], { compare: (a, b) => a[0] === b[0] && a[1] === b[1] });
223
+ return /* @__PURE__ */ jsx(Button, {
224
+ ...props,
225
+ type: "submit",
226
+ variant,
227
+ loading: loading || isSubmitting,
228
+ disabled: disabled || !canSubmit
229
+ });
230
+ }
231
+ /** Resets the form to its default values. */
232
+ function ResetButton({ variant = "secondary", ...props }) {
233
+ const form = useFormContext();
234
+ return /* @__PURE__ */ jsx(Button, {
235
+ ...props,
236
+ type: "button",
237
+ variant,
238
+ onClick: () => form.reset()
239
+ });
240
+ }
241
+ /** Shows `error` or the first form-level validation error in an error Banner. */
242
+ function FormErrorBanner({ error, className }) {
243
+ const form = useFormContext();
244
+ const formError = useSelector(form.store, (s) => firstErrorMessage(s.errors));
245
+ const message = error ?? formError;
246
+ if (!message) return null;
247
+ return /* @__PURE__ */ jsx("div", {
248
+ role: "alert",
249
+ className,
250
+ children: /* @__PURE__ */ jsx(Banner, {
251
+ variant: "error",
252
+ size: "sm",
253
+ icon: /* @__PURE__ */ jsx(WarningCircleIcon, {}),
254
+ description: message
255
+ })
256
+ });
257
+ }
258
+ /**
259
+ * fldr form hook: TanStack Form's `useForm` pre-wired with fldr field and form components.
260
+ * Validators accept functions or any Standard Schema (e.g. zod v4) directly.
261
+ *
262
+ * @example
263
+ * ```tsx
264
+ * const form = useAppForm({
265
+ * defaultValues: { email: "" },
266
+ * validators: { onChange: z.object({ email: z.email() }) },
267
+ * onSubmit: ({ value }) => save(value),
268
+ * });
269
+ * return (
270
+ * <form.AppForm>
271
+ * <form.Form className="flex flex-col gap-3">
272
+ * <form.AppField name="email">{(f) => <f.TextField label="Email" />}</form.AppField>
273
+ * <form.SubmitButton>Save</form.SubmitButton>
274
+ * </form.Form>
275
+ * </form.AppForm>
276
+ * );
277
+ * ```
278
+ */
279
+ const { useAppForm, withForm, withFieldGroup } = createFormHook({
280
+ fieldContext,
281
+ formContext,
282
+ fieldComponents: {
283
+ TextField,
284
+ NumberField,
285
+ TextareaField,
286
+ SelectField,
287
+ CheckboxField,
288
+ SwitchField,
289
+ RadioField
290
+ },
291
+ formComponents: {
292
+ Form,
293
+ SubmitButton,
294
+ ResetButton,
295
+ FormErrorBanner
296
+ }
297
+ });
298
+ /** Field-level validator: fails on empty / whitespace-only strings, `false` or nullish values. */
299
+ function required(message = "Required") {
300
+ return ({ value }) => value == null || value === false || typeof value === "string" && !value.trim() ? message : void 0;
301
+ }
302
+ const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
303
+ /** Field-level validator: fails when a non-empty string is not an email address. Combine with `required` for mandatory fields. */
304
+ function email(message = "Enter a valid email") {
305
+ return ({ value }) => value.trim() && !EMAIL_RE.test(value.trim()) ? message : void 0;
306
+ }
307
+ /** Runs validators in order and returns the first error. */
308
+ function compose(...validators) {
309
+ return (arg) => {
310
+ for (const validate of validators) {
311
+ const error = validate(arg);
312
+ if (error) return error;
313
+ }
314
+ };
315
+ }
316
+ //#endregion
317
+ export { CheckboxField, Form, FormErrorBanner, NumberField, RadioField, ResetButton, SelectField, SubmitButton, SwitchField, TextField, TextareaField, compose, email, fieldContext, firstErrorMessage, formContext, required, useAppForm, useFieldContext, useFormContext, withFieldGroup, withForm };