Skip to content

Commit

Permalink
chore: update playground setup (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeiscontent committed Apr 30, 2024
1 parent be32a14 commit a774b45
Show file tree
Hide file tree
Showing 31 changed files with 3,769 additions and 3,122 deletions.
2 changes: 1 addition & 1 deletion examples/remix/package.json
Expand Up @@ -30,6 +30,6 @@
"typescript": "^4.9.5"
},
"engines": {
"node": ">=14"
"node": "20.x"
}
}
6 changes: 3 additions & 3 deletions guide/package.json
Expand Up @@ -21,7 +21,7 @@
"react-syntax-highlighter": "^15.5.0"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20231218.0",
"@cloudflare/workers-types": "^4.20240419.0",
"@octokit/types": "^12.4.0",
"@remix-run/dev": "^2.5.1",
"@remix-run/eslint-config": "^2.5.1",
Expand All @@ -33,9 +33,9 @@
"eslint": "^8.35.0",
"tailwindcss": "^3.4.0",
"typescript": "^5.3.3",
"wrangler": "^3.22.1"
"wrangler": "^3.28.2"
},
"engines": {
"node": ">=16.13"
"node": "20.x"
}
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -33,7 +33,7 @@
"zod": "3.21.4"
},
"engines": {
"node": ">=20"
"node": "20.x"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": "eslint --ignore-path .gitignore --cache --ext .js,.jsx,.ts,.tsx",
Expand Down
8 changes: 4 additions & 4 deletions playground/app/root.tsx
@@ -1,4 +1,4 @@
import type { V2_MetaFunction, LinksFunction } from '@remix-run/node';
import type { MetaFunction, LinksFunction } from '@remix-run/node';
import {
Links,
LiveReload,
Expand All @@ -7,13 +7,13 @@ import {
Scripts,
ScrollRestoration,
} from '@remix-run/react';
import stylesUrl from '~/styles.css';
import stylesheet from '~/tailwind.css';

export let links: LinksFunction = () => {
return [{ rel: 'stylesheet', href: stylesUrl }];
return [{ rel: 'stylesheet', href: stylesheet }];
};

export const meta: V2_MetaFunction = () => [
export const meta: MetaFunction = () => [
{
charset: 'utf-8',
title: 'Conform Playground',
Expand Down
6 changes: 3 additions & 3 deletions playground/app/routes/_index.tsx
@@ -1,6 +1,6 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
Expand All @@ -10,15 +10,15 @@ const schema = z.object({
name: z.string({ required_error: 'Name is required' }),
});

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
noClientValidate: url.searchParams.get('noClientValidate') === 'yes',
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = parseWithZod(formData, { schema });

Expand Down
6 changes: 3 additions & 3 deletions playground/app/routes/async-validation.tsx
Expand Up @@ -5,7 +5,7 @@ import {
useForm,
} from '@conform-to/react';
import { conformZodMessage, parseWithZod } from '@conform-to/zod';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
Expand Down Expand Up @@ -60,15 +60,15 @@ function createSchema(
});
}

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
noClientValidate: url.searchParams.get('noClientValidate') === 'yes',
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = await parseWithZod(formData, {
schema: (intent) =>
Expand Down
10 changes: 7 additions & 3 deletions playground/app/routes/collection.tsx
@@ -1,6 +1,10 @@
import { getCollectionProps, getFormProps, useForm } from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import { type LoaderArgs, type ActionArgs, json } from '@remix-run/node';
import {
type LoaderFunctionArgs,
type ActionFunctionArgs,
json,
} from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
import { Playground, Field } from '~/components';
Expand All @@ -23,15 +27,15 @@ const schema = z.object({
.min(1, 'Required'),
});

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
noClientValidate: url.searchParams.get('noClientValidate') === 'yes',
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = parseWithZod(formData, { schema });

Expand Down
6 changes: 3 additions & 3 deletions playground/app/routes/custom-inputs.tsx
Expand Up @@ -10,7 +10,7 @@ import {
getSelectProps,
} from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
Expand All @@ -28,7 +28,7 @@ const schema = z.object({
options: z.array(z.string()).min(1, 'At least one option is required'),
});

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
Expand All @@ -37,7 +37,7 @@ export async function loader({ request }: LoaderArgs) {
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = parseWithZod(formData, { schema });

Expand Down
6 changes: 3 additions & 3 deletions playground/app/routes/dom-value.tsx
Expand Up @@ -5,7 +5,7 @@ import {
useForm,
} from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
Expand All @@ -22,15 +22,15 @@ const schema = z.discriminatedUnion('type', [
}),
]);

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
noClientValidate: url.searchParams.get('noClientValidate') === 'yes',
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = parseWithZod(formData, { schema });

Expand Down
6 changes: 3 additions & 3 deletions playground/app/routes/file-upload.tsx
@@ -1,6 +1,6 @@
import { getFormProps, getInputProps, useForm } from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
Expand All @@ -24,15 +24,15 @@ const schema = z.object({
),
});

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
noClientValidate: url.searchParams.get('noClientValidate') === 'yes',
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = parseWithZod(formData, { schema });

Expand Down
4 changes: 2 additions & 2 deletions playground/app/routes/form-attributes.tsx
@@ -1,10 +1,10 @@
import { getFormProps, useForm } from '@conform-to/react';
import { type LoaderArgs } from '@remix-run/node';
import { type LoaderFunctionArgs } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
import { useState } from 'react';
import { Field, Playground } from '~/components';

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
Expand Down
8 changes: 4 additions & 4 deletions playground/app/routes/form-control.tsx
Expand Up @@ -7,7 +7,7 @@ import {
FormProvider,
} from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
Expand All @@ -19,15 +19,15 @@ const schema = z.object({
number: z.number({ required_error: 'Number is required' }),
});

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
noClientValidate: url.searchParams.get('noClientValidate') === 'yes',
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = parseWithZod(formData, { schema });

Expand All @@ -36,7 +36,7 @@ export async function action({ request }: ActionArgs) {

export default function FormControl() {
const { noClientValidate } = useLoaderData<typeof loader>();
const lastResult = useActionData();
const lastResult = useActionData<typeof action>();
const [form, fields] = useForm({
lastResult,
onValidate: !noClientValidate
Expand Down
10 changes: 7 additions & 3 deletions playground/app/routes/input-attributes.tsx
Expand Up @@ -7,7 +7,11 @@ import {
getTextareaProps,
useForm,
} from '@conform-to/react';
import { json, type ActionArgs, type LoaderArgs } from '@remix-run/node';
import {
json,
type ActionFunctionArgs,
type LoaderFunctionArgs,
} from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { Playground, Field, Alert } from '~/components';

Expand All @@ -21,15 +25,15 @@ interface Schema {
languages: string[];
}

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return json({
enableDescription: url.searchParams.get('enableDescription') === 'yes',
});
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const initialValue: Record<string, string | string[]> = {};
const error: Record<string, string[]> = {};
Expand Down
4 changes: 2 additions & 2 deletions playground/app/routes/input-event.tsx
Expand Up @@ -3,11 +3,11 @@ import {
useForm,
unstable_useControl as useControl,
} from '@conform-to/react';
import { type LoaderArgs } from '@remix-run/node';
import { type LoaderFunctionArgs } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
import { type FormEvent, useRef, useState } from 'react';

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
Expand Down
6 changes: 3 additions & 3 deletions playground/app/routes/metadata.tsx
Expand Up @@ -5,7 +5,7 @@ import {
useForm,
} from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
Expand Down Expand Up @@ -54,15 +54,15 @@ const getPrintableValue = (value: unknown) => {
);
};

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
noClientValidate: url.searchParams.get('noClientValidate') === 'yes',
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = parseWithZod(formData, { schema });

Expand Down
8 changes: 4 additions & 4 deletions playground/app/routes/nested-list.tsx
Expand Up @@ -6,7 +6,7 @@ import {
FormStateInput,
} from '@conform-to/react';
import { parseWithZod } from '@conform-to/zod';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import { json } from '@remix-run/node';
import { Form, useActionData, useLoaderData } from '@remix-run/react';
import { z } from 'zod';
Expand All @@ -20,15 +20,15 @@ const schema = z.object({
.array(),
});

export async function loader({ request }: LoaderArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);

return {
noClientValidate: url.searchParams.get('noClientValidate') === 'yes',
};
}

export async function action({ request }: ActionArgs) {
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const submission = parseWithZod(formData, { schema });

Expand All @@ -37,7 +37,7 @@ export async function action({ request }: ActionArgs) {

export default function App() {
const { noClientValidate } = useLoaderData<typeof loader>();
const lastResult = useActionData();
const lastResult = useActionData<typeof action>();
const [form, fields] = useForm({
lastResult,
onValidate: !noClientValidate
Expand Down

0 comments on commit a774b45

Please sign in to comment.