From fb1cd980d8386a5aec173bfe9f06078066a98fe0 Mon Sep 17 00:00:00 2001 From: David Totrashvili <8580261+totraev@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:04:02 +0500 Subject: [PATCH] fix: refactor forms (#65) --- .changeset/giant-queens-mix.md | 5 +++++ src/index.tsx | 14 +++++++------- .../CheckboxField/CheckboxField.stories.tsx | 2 +- .../CheckboxField/CheckboxField.tsx | 2 +- .../{inputs => form}/CheckboxField/index.ts | 0 src/widgets/{inputs => form}/Form/Form.stories.tsx | 2 +- src/widgets/{inputs => form}/Form/Form.tsx | 0 src/widgets/{inputs => form}/Form/index.tsx | 0 .../NumberField/NumberField.stories.tsx | 2 +- .../{inputs => form}/NumberField/NumberField.tsx | 4 ++-- src/widgets/{inputs => form}/NumberField/index.ts | 0 .../RadioField/RadioField.stories.tsx | 2 +- .../{inputs => form}/RadioField/RadioField.tsx | 0 src/widgets/{inputs => form}/RadioField/index.ts | 0 .../SelectField/SelectField.stories.tsx | 0 .../{inputs => form}/SelectField/SelectField.tsx | 4 ++-- src/widgets/{inputs => form}/SelectField/index.ts | 0 .../TextField/TextField.stories.tsx | 2 +- .../{inputs => form}/TextField/TextField.tsx | 4 ++-- src/widgets/{inputs => form}/TextField/index.ts | 0 src/widgets/{inputs => form}/hooks.ts | 0 src/widgets/{inputs => form}/types.ts | 0 22 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 .changeset/giant-queens-mix.md rename src/widgets/{inputs => form}/CheckboxField/CheckboxField.stories.tsx (92%) rename src/widgets/{inputs => form}/CheckboxField/CheckboxField.tsx (94%) rename src/widgets/{inputs => form}/CheckboxField/index.ts (100%) rename src/widgets/{inputs => form}/Form/Form.stories.tsx (94%) rename src/widgets/{inputs => form}/Form/Form.tsx (100%) rename src/widgets/{inputs => form}/Form/index.tsx (100%) rename src/widgets/{inputs => form}/NumberField/NumberField.stories.tsx (94%) rename src/widgets/{inputs => form}/NumberField/NumberField.tsx (93%) rename src/widgets/{inputs => form}/NumberField/index.ts (100%) rename src/widgets/{inputs => form}/RadioField/RadioField.stories.tsx (91%) rename src/widgets/{inputs => form}/RadioField/RadioField.tsx (100%) rename src/widgets/{inputs => form}/RadioField/index.ts (100%) rename src/widgets/{inputs => form}/SelectField/SelectField.stories.tsx (100%) rename src/widgets/{inputs => form}/SelectField/SelectField.tsx (94%) rename src/widgets/{inputs => form}/SelectField/index.ts (100%) rename src/widgets/{inputs => form}/TextField/TextField.stories.tsx (94%) rename src/widgets/{inputs => form}/TextField/TextField.tsx (92%) rename src/widgets/{inputs => form}/TextField/index.ts (100%) rename src/widgets/{inputs => form}/hooks.ts (100%) rename src/widgets/{inputs => form}/types.ts (100%) diff --git a/.changeset/giant-queens-mix.md b/.changeset/giant-queens-mix.md new file mode 100644 index 0000000..5ae321d --- /dev/null +++ b/.changeset/giant-queens-mix.md @@ -0,0 +1,5 @@ +--- +"@babylonlabs-io/bbn-core-ui": patch +--- + +refactor form diff --git a/src/index.tsx b/src/index.tsx index 409ca6f..3559014 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -13,12 +13,12 @@ export * from "./components/Loader"; export * from "./components/Table"; export * from "./components/Popover"; -export * from "./widgets/inputs/Form"; -export * from "./widgets/inputs/NumberField"; -export * from "./widgets/inputs/TextField"; -export * from "./widgets/inputs/CheckboxField"; -export * from "./widgets/inputs/RadioField"; -export * from "./widgets/inputs/SelectField"; -export * from "./widgets/inputs/hooks"; +export * from "./widgets/form/Form"; +export * from "./widgets/form/NumberField"; +export * from "./widgets/form/TextField"; +export * from "./widgets/form/CheckboxField"; +export * from "./widgets/form/RadioField"; +export * from "./widgets/form/SelectField"; +export * from "./widgets/form/hooks"; export { ScrollLocker } from "./context/Dialog.context"; diff --git a/src/widgets/inputs/CheckboxField/CheckboxField.stories.tsx b/src/widgets/form/CheckboxField/CheckboxField.stories.tsx similarity index 92% rename from src/widgets/inputs/CheckboxField/CheckboxField.stories.tsx rename to src/widgets/form/CheckboxField/CheckboxField.stories.tsx index 91acb74..5445bd8 100644 --- a/src/widgets/inputs/CheckboxField/CheckboxField.stories.tsx +++ b/src/widgets/form/CheckboxField/CheckboxField.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from "@storybook/react"; -import { Form } from "../Form"; +import { Form } from "@/widgets/form/Form"; import { CheckboxField } from "./CheckboxField"; diff --git a/src/widgets/inputs/CheckboxField/CheckboxField.tsx b/src/widgets/form/CheckboxField/CheckboxField.tsx similarity index 94% rename from src/widgets/inputs/CheckboxField/CheckboxField.tsx rename to src/widgets/form/CheckboxField/CheckboxField.tsx index b3814ff..9dac4c8 100644 --- a/src/widgets/inputs/CheckboxField/CheckboxField.tsx +++ b/src/widgets/form/CheckboxField/CheckboxField.tsx @@ -1,5 +1,5 @@ import { type CheckboxProps, Checkbox } from "@/components/Form/Checkbox"; -import { useField } from "../hooks"; +import { useField } from "@/widgets/form/hooks"; export interface CheckboxFieldProps extends CheckboxProps { name: string; diff --git a/src/widgets/inputs/CheckboxField/index.ts b/src/widgets/form/CheckboxField/index.ts similarity index 100% rename from src/widgets/inputs/CheckboxField/index.ts rename to src/widgets/form/CheckboxField/index.ts diff --git a/src/widgets/inputs/Form/Form.stories.tsx b/src/widgets/form/Form/Form.stories.tsx similarity index 94% rename from src/widgets/inputs/Form/Form.stories.tsx rename to src/widgets/form/Form/Form.stories.tsx index 95f28f2..bf6429e 100644 --- a/src/widgets/inputs/Form/Form.stories.tsx +++ b/src/widgets/form/Form/Form.stories.tsx @@ -3,7 +3,7 @@ import * as yup from "yup"; import { Form } from "./Form"; -import { useField } from "../hooks"; +import { useField } from "@/widgets/form/hooks"; import { Input, FormControl } from "@/components/Form"; const meta: Meta = { diff --git a/src/widgets/inputs/Form/Form.tsx b/src/widgets/form/Form/Form.tsx similarity index 100% rename from src/widgets/inputs/Form/Form.tsx rename to src/widgets/form/Form/Form.tsx diff --git a/src/widgets/inputs/Form/index.tsx b/src/widgets/form/Form/index.tsx similarity index 100% rename from src/widgets/inputs/Form/index.tsx rename to src/widgets/form/Form/index.tsx diff --git a/src/widgets/inputs/NumberField/NumberField.stories.tsx b/src/widgets/form/NumberField/NumberField.stories.tsx similarity index 94% rename from src/widgets/inputs/NumberField/NumberField.stories.tsx rename to src/widgets/form/NumberField/NumberField.stories.tsx index 2f22ae0..5d6d0da 100644 --- a/src/widgets/inputs/NumberField/NumberField.stories.tsx +++ b/src/widgets/form/NumberField/NumberField.stories.tsx @@ -2,7 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react"; import * as yup from "yup"; import { NumberField } from "./NumberField"; -import { Form } from "../Form"; +import { Form } from "@/widgets/form/Form"; const meta: Meta = { component: NumberField, diff --git a/src/widgets/inputs/NumberField/NumberField.tsx b/src/widgets/form/NumberField/NumberField.tsx similarity index 93% rename from src/widgets/inputs/NumberField/NumberField.tsx rename to src/widgets/form/NumberField/NumberField.tsx index 507781e..1e3a204 100644 --- a/src/widgets/inputs/NumberField/NumberField.tsx +++ b/src/widgets/form/NumberField/NumberField.tsx @@ -1,8 +1,8 @@ import { ChangeEventHandler, ReactNode } from "react"; import { FormControl, Input } from "@/components/Form"; -import type { FieldProps } from "../types"; -import { useField } from "../hooks"; +import type { FieldProps } from "@/widgets/form/types"; +import { useField } from "@/widgets/form/hooks"; export interface NumberFieldProps extends FieldProps { type?: "text" | "hidden" | "number" | "password" | "tel" | "url" | "email"; diff --git a/src/widgets/inputs/NumberField/index.ts b/src/widgets/form/NumberField/index.ts similarity index 100% rename from src/widgets/inputs/NumberField/index.ts rename to src/widgets/form/NumberField/index.ts diff --git a/src/widgets/inputs/RadioField/RadioField.stories.tsx b/src/widgets/form/RadioField/RadioField.stories.tsx similarity index 91% rename from src/widgets/inputs/RadioField/RadioField.stories.tsx rename to src/widgets/form/RadioField/RadioField.stories.tsx index 1011ace..fe647e1 100644 --- a/src/widgets/inputs/RadioField/RadioField.stories.tsx +++ b/src/widgets/form/RadioField/RadioField.stories.tsx @@ -1,6 +1,6 @@ import type { Meta, StoryObj } from "@storybook/react"; -import { Form } from "../Form"; +import { Form } from "@/widgets/form/Form"; import { RadioField } from "./RadioField"; diff --git a/src/widgets/inputs/RadioField/RadioField.tsx b/src/widgets/form/RadioField/RadioField.tsx similarity index 100% rename from src/widgets/inputs/RadioField/RadioField.tsx rename to src/widgets/form/RadioField/RadioField.tsx diff --git a/src/widgets/inputs/RadioField/index.ts b/src/widgets/form/RadioField/index.ts similarity index 100% rename from src/widgets/inputs/RadioField/index.ts rename to src/widgets/form/RadioField/index.ts diff --git a/src/widgets/inputs/SelectField/SelectField.stories.tsx b/src/widgets/form/SelectField/SelectField.stories.tsx similarity index 100% rename from src/widgets/inputs/SelectField/SelectField.stories.tsx rename to src/widgets/form/SelectField/SelectField.stories.tsx diff --git a/src/widgets/inputs/SelectField/SelectField.tsx b/src/widgets/form/SelectField/SelectField.tsx similarity index 94% rename from src/widgets/inputs/SelectField/SelectField.tsx rename to src/widgets/form/SelectField/SelectField.tsx index 28c75c4..29e25bd 100644 --- a/src/widgets/inputs/SelectField/SelectField.tsx +++ b/src/widgets/form/SelectField/SelectField.tsx @@ -1,8 +1,8 @@ import { ReactNode } from "react"; import { type Option, FormControl, Select } from "@/components/Form"; -import type { FieldProps } from "../types"; -import { useField } from "../hooks"; +import type { FieldProps } from "@/widgets/form/types"; +import { useField } from "@/widgets/form/hooks"; export interface SelectFieldProps extends FieldProps { open?: boolean; diff --git a/src/widgets/inputs/SelectField/index.ts b/src/widgets/form/SelectField/index.ts similarity index 100% rename from src/widgets/inputs/SelectField/index.ts rename to src/widgets/form/SelectField/index.ts diff --git a/src/widgets/inputs/TextField/TextField.stories.tsx b/src/widgets/form/TextField/TextField.stories.tsx similarity index 94% rename from src/widgets/inputs/TextField/TextField.stories.tsx rename to src/widgets/form/TextField/TextField.stories.tsx index fa49dfc..82a6952 100644 --- a/src/widgets/inputs/TextField/TextField.stories.tsx +++ b/src/widgets/form/TextField/TextField.stories.tsx @@ -2,7 +2,7 @@ import type { Meta, StoryObj } from "@storybook/react"; import * as yup from "yup"; import { TextField } from "./TextField"; -import { Form } from "../Form"; +import { Form } from "@/widgets/form/Form"; const meta: Meta = { component: TextField, diff --git a/src/widgets/inputs/TextField/TextField.tsx b/src/widgets/form/TextField/TextField.tsx similarity index 92% rename from src/widgets/inputs/TextField/TextField.tsx rename to src/widgets/form/TextField/TextField.tsx index 9c3d08d..d90d9e4 100644 --- a/src/widgets/inputs/TextField/TextField.tsx +++ b/src/widgets/form/TextField/TextField.tsx @@ -1,8 +1,8 @@ import { ReactNode } from "react"; import { FormControl, Input } from "@/components/Form"; -import type { FieldProps } from "../types"; -import { useField } from "../hooks"; +import type { FieldProps } from "@/widgets/form/types"; +import { useField } from "@/widgets/form/hooks"; export interface TextFieldProps extends FieldProps { type?: "text" | "hidden" | "number" | "password" | "tel" | "url" | "email"; diff --git a/src/widgets/inputs/TextField/index.ts b/src/widgets/form/TextField/index.ts similarity index 100% rename from src/widgets/inputs/TextField/index.ts rename to src/widgets/form/TextField/index.ts diff --git a/src/widgets/inputs/hooks.ts b/src/widgets/form/hooks.ts similarity index 100% rename from src/widgets/inputs/hooks.ts rename to src/widgets/form/hooks.ts diff --git a/src/widgets/inputs/types.ts b/src/widgets/form/types.ts similarity index 100% rename from src/widgets/inputs/types.ts rename to src/widgets/form/types.ts