@boxcustodia/library 2.0.0-alpha.21 → 2.0.0-alpha.22
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Form as FormPrimitive } from '@base-ui/react/form';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
export type FormProps = FormPrimitive.Props
|
|
4
|
-
export declare function Form(props: FormProps): React.ReactElement;
|
|
3
|
+
export type FormProps<TValues extends Record<string, any> = Record<string, any>> = FormPrimitive.Props<TValues>;
|
|
4
|
+
export declare function Form<TValues extends Record<string, any> = Record<string, any>>(props: FormProps<TValues>): React.ReactElement;
|
|
5
5
|
export { FormPrimitive };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boxcustodia/library",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -81,14 +81,14 @@
|
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@biomejs/biome": "^2.3.8",
|
|
84
|
-
"@chromatic-com/storybook": "^5.1
|
|
84
|
+
"@chromatic-com/storybook": "^5.2.1",
|
|
85
85
|
"@faker-js/faker": "^10.1.0",
|
|
86
86
|
"@headless-tree/react": "^1.7.0",
|
|
87
|
-
"@storybook/addon-docs": "10.3
|
|
88
|
-
"@storybook/addon-links": "10.3
|
|
87
|
+
"@storybook/addon-docs": "10.4.3",
|
|
88
|
+
"@storybook/addon-links": "10.4.3",
|
|
89
89
|
"@storybook/addon-mcp": "^0.6.0",
|
|
90
|
-
"@storybook/addon-onboarding": "10.3
|
|
91
|
-
"@storybook/react-vite": "10.3
|
|
90
|
+
"@storybook/addon-onboarding": "10.4.3",
|
|
91
|
+
"@storybook/react-vite": "10.4.3",
|
|
92
92
|
"@tailwindcss/cli": "^4.1.18",
|
|
93
93
|
"@tailwindcss/vite": "^4.1.18",
|
|
94
94
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"react-markdown": "^10.1.0",
|
|
110
110
|
"rollup-plugin-preserve-directives": "^0.4.0",
|
|
111
111
|
"standard-version": "^9.5.0",
|
|
112
|
-
"storybook": "10.3
|
|
112
|
+
"storybook": "10.4.3",
|
|
113
113
|
"storybook-addon-tag-badges": "^3.1.0",
|
|
114
114
|
"tailwindcss": "^4.1.18",
|
|
115
115
|
"typescript": "^5.9.3",
|
|
@@ -365,6 +365,39 @@ export const OnFormSubmit: Story = {
|
|
|
365
365
|
},
|
|
366
366
|
};
|
|
367
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Pass a type argument to `Form` to get a typed `onFormSubmit` callback.
|
|
370
|
+
* `data` is inferred as `{ email: string; username: string }` — no cast needed.
|
|
371
|
+
*/
|
|
372
|
+
export const TypedOnFormSubmit: Story = {
|
|
373
|
+
render: () => {
|
|
374
|
+
const [values, setValues] = useState<{
|
|
375
|
+
email: string;
|
|
376
|
+
username: string;
|
|
377
|
+
} | null>(null);
|
|
378
|
+
|
|
379
|
+
return (
|
|
380
|
+
<Form<{ email: string; username: string }>
|
|
381
|
+
className="flex w-80 flex-col gap-4"
|
|
382
|
+
onFormSubmit={(data) => setValues(data)}
|
|
383
|
+
>
|
|
384
|
+
<Field name="email" label="Email">
|
|
385
|
+
<Input type="email" required placeholder="you@example.com" />
|
|
386
|
+
</Field>
|
|
387
|
+
<Field name="username" label="Username">
|
|
388
|
+
<Input required placeholder="e.g. jane_doe" />
|
|
389
|
+
</Field>
|
|
390
|
+
<Button type="submit">Submit</Button>
|
|
391
|
+
{values && (
|
|
392
|
+
<pre className="rounded-md bg-muted p-3 text-xs">
|
|
393
|
+
{JSON.stringify(values, null, 2)}
|
|
394
|
+
</pre>
|
|
395
|
+
)}
|
|
396
|
+
</Form>
|
|
397
|
+
);
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
|
|
368
401
|
const ZodSchema = z.object({
|
|
369
402
|
name: z.string().min(1, "Name is required."),
|
|
370
403
|
age: z.coerce
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
import { Form as FormPrimitive } from "@base-ui/react/form";
|
|
4
4
|
import type React from "react";
|
|
5
5
|
|
|
6
|
-
export type FormProps =
|
|
6
|
+
export type FormProps<TValues extends Record<string, any> = Record<string, any>> =
|
|
7
|
+
FormPrimitive.Props<TValues>;
|
|
7
8
|
|
|
8
|
-
export function Form
|
|
9
|
+
export function Form<TValues extends Record<string, any> = Record<string, any>>(
|
|
10
|
+
props: FormProps<TValues>,
|
|
11
|
+
): React.ReactElement {
|
|
9
12
|
return <FormPrimitive data-slot="form" {...props} />;
|
|
10
13
|
}
|
|
11
14
|
|