From 3b785f37e36cb2f43cf0a03ff18e3b7268d9ce40 Mon Sep 17 00:00:00 2001 From: connoratrug Date: Thu, 23 Jan 2025 10:43:08 +0100 Subject: [PATCH 1/7] feat: Boolean field input --- .../components/input/Boolean.vue | 64 +++++++++++++++++++ .../components/input/Radio.vue | 4 +- .../components/input/RadioGroup.vue | 60 ++++++++++------- .../pages/input/Boolean.story.vue | 19 ++++++ apps/tailwind-components/types/types.ts | 6 ++ 5 files changed, 128 insertions(+), 25 deletions(-) create mode 100644 apps/tailwind-components/components/input/Boolean.vue create mode 100644 apps/tailwind-components/pages/input/Boolean.story.vue diff --git a/apps/tailwind-components/components/input/Boolean.vue b/apps/tailwind-components/components/input/Boolean.vue new file mode 100644 index 0000000000..7bf147d505 --- /dev/null +++ b/apps/tailwind-components/components/input/Boolean.vue @@ -0,0 +1,64 @@ + + + diff --git a/apps/tailwind-components/components/input/Radio.vue b/apps/tailwind-components/components/input/Radio.vue index 95fd10a23b..408c36ef78 100644 --- a/apps/tailwind-components/components/input/Radio.vue +++ b/apps/tailwind-components/components/input/Radio.vue @@ -9,8 +9,8 @@ diff --git a/apps/tailwind-components/components/input/RadioGroup.vue b/apps/tailwind-components/components/input/RadioGroup.vue index 70b223be09..bb8814a2a5 100644 --- a/apps/tailwind-components/components/input/RadioGroup.vue +++ b/apps/tailwind-components/components/input/RadioGroup.vue @@ -1,19 +1,27 @@ -
- -
+ + diff --git a/apps/tailwind-components/pages/input/Boolean.story.vue b/apps/tailwind-components/pages/input/Boolean.story.vue new file mode 100644 index 0000000000..ecf309ba38 --- /dev/null +++ b/apps/tailwind-components/pages/input/Boolean.story.vue @@ -0,0 +1,19 @@ + + + diff --git a/apps/tailwind-components/types/types.ts b/apps/tailwind-components/types/types.ts index 1795d5ee3d..3a51a77fd7 100644 --- a/apps/tailwind-components/types/types.ts +++ b/apps/tailwind-components/types/types.ts @@ -91,4 +91,10 @@ export interface IDocumentation { file: IFile; } +export interface RadioOptionsDataIF { + value: string | boolean; + label?: string; + checked?: boolean | undefined; +} + \ No newline at end of file From a7c0c64c96926f4e30a59f7dff691f1893e300df Mon Sep 17 00:00:00 2001 From: connoratrug Date: Thu, 23 Jan 2025 11:00:30 +0100 Subject: [PATCH 2/7] add to form wip --- .../components/form/FieldInput.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/tailwind-components/components/form/FieldInput.vue b/apps/tailwind-components/components/form/FieldInput.vue index b15b55b1b6..3056bdd8bd 100644 --- a/apps/tailwind-components/components/form/FieldInput.vue +++ b/apps/tailwind-components/components/form/FieldInput.vue @@ -51,7 +51,7 @@ function validate(value: columnValue) { @focus="$emit('focus')" @update:modelValue="$emit('update:modelValue', $event)" @error="$emit('error', $event)" - > + /> + /> + From 62c96e301eb2075c6c213d7c5f205105181ebb4a Mon Sep 17 00:00:00 2001 From: connoratrug Date: Thu, 23 Jan 2025 15:29:16 +0100 Subject: [PATCH 3/7] add boolean field --- apps/metadata-utils/src/types.ts | 2 +- .../components/form/FieldInput.vue | 2 +- .../components/input/Boolean.vue | 24 ++++++++++++------- apps/tailwind-components/pages/Form.story.vue | 12 ++++++---- .../pages/input/Boolean.story.vue | 15 +++++++++--- .../tests/components/form/renderForm.spec.ts | 18 +++++++------- 6 files changed, 46 insertions(+), 27 deletions(-) diff --git a/apps/metadata-utils/src/types.ts b/apps/metadata-utils/src/types.ts index c31dd39a4f..10c3b47120 100644 --- a/apps/metadata-utils/src/types.ts +++ b/apps/metadata-utils/src/types.ts @@ -92,7 +92,7 @@ export interface IFieldError { } export type columnId = string; -export type columnValue = string | number | boolean | columnValueObject; +export type columnValue = string | number | boolean | null | columnValueObject; interface columnValueObject { [x: string]: columnValue; diff --git a/apps/tailwind-components/components/form/FieldInput.vue b/apps/tailwind-components/components/form/FieldInput.vue index 3056bdd8bd..a8137ff618 100644 --- a/apps/tailwind-components/components/form/FieldInput.vue +++ b/apps/tailwind-components/components/form/FieldInput.vue @@ -69,7 +69,7 @@ function validate(value: columnValue) { :id="id" :label="label" :required="required" - :modelValue="data as boolean" + :modelValue="data === true || data === false ? data : null" @focus="$emit('focus')" @update:modelValue="$emit('update:modelValue', $event)" @error="$emit('error', $event)" diff --git a/apps/tailwind-components/components/input/Boolean.vue b/apps/tailwind-components/components/input/Boolean.vue index 7bf147d505..27c6fbad02 100644 --- a/apps/tailwind-components/components/input/Boolean.vue +++ b/apps/tailwind-components/components/input/Boolean.vue @@ -2,15 +2,13 @@ - - {{ modelValue }} diff --git a/apps/tailwind-components/tests/components/form/renderForm.spec.ts b/apps/tailwind-components/tests/components/form/renderForm.spec.ts index afea50f44e..f782e9545a 100644 --- a/apps/tailwind-components/tests/components/form/renderForm.spec.ts +++ b/apps/tailwind-components/tests/components/form/renderForm.spec.ts @@ -7,13 +7,15 @@ const route = playwrightConfig?.use?.baseURL?.startsWith("http://localhost") test("it should render the form", async ({ page }) => { await page.goto(`${route}Form.story`); - await page.goto( - "https://emx2.dev.molgenis.org/apps/tailwind-components/#/Form.story" - ); - await expect(page.getByRole("main")).toContainText("bool"); - await expect(page.getByRole("main")).toContainText( - "place holder for field type BOOL" - ); + await page.goto("http://localhost:3000/"); + await page.getByRole("link", { name: "Form" }).click(); + await page.getByLabel("name").click(); + await page.getByLabel("name").fill("test"); + await expect(page.getByText("test")).toBeVisible(); + await expect(page.getByRole("main")).toContainText("test"); + await page.goto("http://localhost:3000/Form.story"); + await expect(page.getByRole("main")).toContainText("name"); + await expect(page.getByRole("main")).toContainText("the name"); await expect(page.getByRole("main")).toContainText("date"); await expect(page.getByRole("main")).toContainText("name"); await expect(page.getByRole("main")).toContainText("Required"); @@ -26,6 +28,4 @@ test("it should handle input", async ({ page }) => { await page.getByLabel("name").click({ delay: 500 }); // wait for hydration to complete await page.getByLabel("name").pressSequentially("test"); await expect(page.getByLabel("name")).toHaveValue("test"); - await page.getByRole("heading", { name: "Values" }).click(); - await expect(page.getByRole("definition")).toContainText("test"); }); From 1a514805d50f29ada8537073c111594fe250cc66 Mon Sep 17 00:00:00 2001 From: connoratrug Date: Thu, 23 Jan 2025 16:02:02 +0100 Subject: [PATCH 4/7] fix test --- .../tests/components/form/renderForm.spec.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/tailwind-components/tests/components/form/renderForm.spec.ts b/apps/tailwind-components/tests/components/form/renderForm.spec.ts index f782e9545a..d9ec6614ea 100644 --- a/apps/tailwind-components/tests/components/form/renderForm.spec.ts +++ b/apps/tailwind-components/tests/components/form/renderForm.spec.ts @@ -5,15 +5,17 @@ const route = playwrightConfig?.use?.baseURL?.startsWith("http://localhost") ? "" : "/apps/tailwind-components/#/"; -test("it should render the form", async ({ page }) => { +test.beforeEach(async ({ page }) => { await page.goto(`${route}Form.story`); - await page.goto("http://localhost:3000/"); + await page.getByLabel("name").click({ delay: 500 }); // wait for hydration to complete +}); + +test("it should render the form", async ({ page }) => { await page.getByRole("link", { name: "Form" }).click(); await page.getByLabel("name").click(); await page.getByLabel("name").fill("test"); await expect(page.getByText("test")).toBeVisible(); await expect(page.getByRole("main")).toContainText("test"); - await page.goto("http://localhost:3000/Form.story"); await expect(page.getByRole("main")).toContainText("name"); await expect(page.getByRole("main")).toContainText("the name"); await expect(page.getByRole("main")).toContainText("date"); @@ -24,8 +26,6 @@ test("it should render the form", async ({ page }) => { }); test("it should handle input", async ({ page }) => { - await page.goto(`${route}Form.story`); - await page.getByLabel("name").click({ delay: 500 }); // wait for hydration to complete await page.getByLabel("name").pressSequentially("test"); await expect(page.getByLabel("name")).toHaveValue("test"); }); From aa5e348ee52a4ae3ea7b8c4bafa7672f1d2f2984 Mon Sep 17 00:00:00 2001 From: connoratrug Date: Fri, 24 Jan 2025 08:44:47 +0100 Subject: [PATCH 5/7] fix merge issue --- .../tests/components/form/renderForm.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/tailwind-components/tests/components/form/renderForm.spec.ts b/apps/tailwind-components/tests/components/form/renderForm.spec.ts index b9142215cd..74601776e7 100644 --- a/apps/tailwind-components/tests/components/form/renderForm.spec.ts +++ b/apps/tailwind-components/tests/components/form/renderForm.spec.ts @@ -11,8 +11,6 @@ test.beforeEach(async ({ page }) => { }); test("it should render the form", async ({ page }) => { - await expect(page.getByText("test")).toBeVisible(); - await expect(page.getByRole("main")).toContainText("test"); await expect(page.getByRole("main")).toContainText("name"); await expect(page.getByRole("main")).toContainText("the name"); await expect(page.getByRole("main")).toContainText("date"); From c4912e97e2eb0839ec09610fdb7d85d08c2a6088 Mon Sep 17 00:00:00 2001 From: connoratrug Date: Mon, 27 Jan 2025 16:08:24 +0100 Subject: [PATCH 6/7] fix for unwanted scroll issue see https://github.com/tailwindlabs/tailwindcss/discussions/12429 --- apps/tailwind-components/components/input/RadioGroup.vue | 2 +- apps/tailwind-components/pages/input/Boolean.story.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/tailwind-components/components/input/RadioGroup.vue b/apps/tailwind-components/components/input/RadioGroup.vue index bb8814a2a5..faf7adb09d 100644 --- a/apps/tailwind-components/components/input/RadioGroup.vue +++ b/apps/tailwind-components/components/input/RadioGroup.vue @@ -10,7 +10,7 @@
-
Be polite: {{ modelValue3 }}
+
Be polite: {{ politeBoolean }}
diff --git a/apps/tailwind-components/components/input/RadioGroup.vue b/apps/tailwind-components/components/input/RadioGroup.vue index faf7adb09d..0e3cda6a6a 100644 --- a/apps/tailwind-components/components/input/RadioGroup.vue +++ b/apps/tailwind-components/components/input/RadioGroup.vue @@ -32,12 +32,7 @@