From 7277b3edac973be2b9e9296d9bd863de79c90995 Mon Sep 17 00:00:00 2001 From: Felipe Freitag Vargas Date: Tue, 18 Jul 2023 19:02:22 -0300 Subject: [PATCH 1/2] Pin node version and set playwright output to line --- apps/web/package.json | 3 +++ apps/web/playwright.config.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/package.json b/apps/web/package.json index 9d46f6f..eaaf3d2 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -63,5 +63,8 @@ }, "engines": { "node": ">=14" + }, + "volta": { + "node": "18.16.1" } } diff --git a/apps/web/playwright.config.ts b/apps/web/playwright.config.ts index 7d90f31..ad4e72e 100644 --- a/apps/web/playwright.config.ts +++ b/apps/web/playwright.config.ts @@ -28,7 +28,7 @@ const config: PlaywrightTestConfig = { /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: 'line', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ From 1c7e0aa27e0c08ffea4420c00e54d2f1d6d81fa5 Mon Sep 17 00:00:00 2001 From: Felipe Freitag Vargas Date: Tue, 18 Jul 2023 19:08:52 -0300 Subject: [PATCH 2/2] Add autocomplete attribute support --- .../test-examples/field-with-autocomplete.tsx | 117 ++++++++++++++++++ .../forms/field-with-autocomplete.spec.ts | 39 ++++++ packages/remix-forms/src/createField.tsx | 4 + 3 files changed, 160 insertions(+) create mode 100644 apps/web/app/routes/test-examples/field-with-autocomplete.tsx create mode 100644 apps/web/tests/examples/forms/field-with-autocomplete.spec.ts diff --git a/apps/web/app/routes/test-examples/field-with-autocomplete.tsx b/apps/web/app/routes/test-examples/field-with-autocomplete.tsx new file mode 100644 index 0000000..05e25c7 --- /dev/null +++ b/apps/web/app/routes/test-examples/field-with-autocomplete.tsx @@ -0,0 +1,117 @@ +import hljs from 'highlight.js/lib/common' +import type { + ActionFunction, + LoaderFunction, + MetaFunction, +} from '@remix-run/node' +import { formAction } from '~/formAction' +import { z } from 'zod' +import Form from '~/ui/form' +import { metaTags } from '~/helpers' +import { makeDomainFunction } from 'domain-functions' +import Example from '~/ui/example' + +const title = 'Field with autocomplete' +const description = + 'In this example, we pass a autocomplete prop to a field without children.' + +export const meta: MetaFunction = () => metaTags({ title, description }) + +const schema = z.object({ + name: z.string().min(1), + code: z.number().int().optional(), + organization: z.string().optional(), + organizationTitle: z.enum(['director', 'manager', 'employee']), + streetAddress: z.string().optional(), + country: z.string().optional(), + postalCode: z.string().optional(), + addressLine1: z.string().optional(), +}) + +export const loader: LoaderFunction = () => ({ + code: hljs.highlight('', { language: 'ts' }).value, +}) + +const mutation = makeDomainFunction(schema)(async (values) => values) + +export const action: ActionFunction = async ({ request }) => + formAction({ request, schema, mutation }) + +export default function Component() { + return ( + +
+ {({ Field, Errors, Button }) => ( + <> + {/* Text field */} + + {/* Numeric field */} + + {({ Label, Input, Errors }) => ( + <> + + + + + )} + + {/* Select field */} + + {/* Textarea field */} + + {/* Text field child */} + + {({ Label, Input, Errors }) => ( + <> + + + + + )} + + {/* Smart input child*/} + + {({ Label, SmartInput, Errors }) => ( + <> + + + + + )} + + {/* Select child */} + + {({ Label, Select, Errors }) => ( + <> + + + + + )} + + {/* Textarea child */} + + {({ Label, Multiline, Errors }) => ( + <> + + + + + + )} + + +