diff --git a/docs/DateField.mdx b/docs/DateField.mdx new file mode 100644 index 0000000..5ba2e2a --- /dev/null +++ b/docs/DateField.mdx @@ -0,0 +1,65 @@ +## Title + +DateField + +## Description + +A reusable component for selecting dates, featuring a calendar popup and error handling. + +## Installation + +**optional** + +```bash +npm i zod @hookform/resolvers +``` + +## Library + +- react-hook-form `<=^7.51.3` +- zod, @hookform/resolvers (optional) + +## Anatomy + +- **`formMethod`** : Object containing form management methods and state from React Hook Form. +- **`label`**: The label text displayed above the input field. +- **`name`**: The unique identifier for the input field. +- **`days`**: The number of days to calculate disabled date ranges. +- **`color`**(optional): The color theme for the input field. It can be `'yellow' | 'purple'`, defaulting to `'yellow'`. + +## Usage + +```tsx +import { DateField } from 'ggf-ui'; +import { FormProvider, useForm } from 'react-hook-form'; +import { zodResolver } from '@hookform/resolvers/zod'; // optional +import { z } from 'zod'; // optional +``` + +```tsx +const Schema = z.object({ + DateField: z.string().min(1), +}); // optional + +const methods = useForm({ + mode: 'all', + resolver: zodResolver(Schema), // optional +}); + +const onSubmit = (data: object) => { + console.log(data); +}; + +return ( + +
+ + + +
+); +``` + +## UI + + diff --git a/docs/FormDropdown.mdx b/docs/FormDropdown.mdx new file mode 100644 index 0000000..3bb28af --- /dev/null +++ b/docs/FormDropdown.mdx @@ -0,0 +1,74 @@ +## Title + +FormDropdown + +## Description + +A customizable dropdown menu for forms, allowing users to select from a list of options. + +## Installation + +**optional** + +```bash +npm i zod @hookform/resolvers +``` + +## Library + +- react-hook-form `<=^7.51.3` +- zod, @hookform/resolvers (optional) + +## Anatomy + +- **`formMethod`** : Object containing form management methods and state from React Hook Form. +- **`name`**: The unique identifier for the dropdown input. +- **`label`** (optional): The text label displayed above the dropdown. +- **`options`**: An array of objects representing the dropdown options. + - **`title`**: The text to be displayed on option. + - **`value`**: The value of option. +- **`isSmall`** (optional): A boolean indicating whether the dropdown should be rendered in a smaller size. +- **`isDisabled`** (optional): A boolean indicating whether the dropdown should be disabled. +- **`color`** (optional): The color theme for the dropdown. It can be `'purple' | 'yellow'`. Defaults to `'purple'` + +## Usage + +```tsx +import { FormDropdown } from 'ggf-ui'; +import { FormProvider, useForm } from 'react-hook-form'; +import { zodResolver } from '@hookform/resolvers/zod'; // optional +import { z } from 'zod'; // optional +``` + +```tsx +const Schema = z.object({ + formdropdown: z.number().min(1), +}); // optional + +const methods = useForm({ + mode: 'all', + resolver: zodResolver(Schema), // optional +}); + +const options = [ + { title: 'number 1', value: 1 }, + { title: 'number 2', value: 2 }, +]; + +const onSubmit = (data: object) => { + console.log(data); +}; + +return ( + +
+ + + +
+); +``` + +## UI + + diff --git a/docs/ImageField.mdx b/docs/ImageField.mdx new file mode 100644 index 0000000..0e0d827 --- /dev/null +++ b/docs/ImageField.mdx @@ -0,0 +1,42 @@ +## Title + +ImageField + +## Description + +The ImageField component allows users to upload images with customizable features such as maximum file size, maximum number of files, and visual representations of the uploaded images. It provides a dropzone area for dragging and dropping files, along with a list of uploaded files with options for deletion. + +## Anatomy + +- **`label`**: The label displayed above the ImageField component. +- **`modalTitle`**: The title of the confirmation modal displayed when file upload exceeds limits. +- **`modalState`**: The state of the confirmation modal. +- **`modalDescription`**: The description text displayed in the confirmation modal. +- **`modalButtonMessage`**: The message displayed on the confirmation modal button. +- **`onFilesUpdate`**: A function to update the list of files after upload or deletion. +- **`maxMB`** (optional): The maximum file size allowed for upload, in `megabytes`. Defaults to `50MB`. +- **`maxFiles`** (optional): The maximum number of files allowed for upload. Defaults to `5` files. +- **`recommendMessage`** (optional): Additional recommendation message displayed next to the label. +- **`dropzoneMessage`** (optional): The message displayed within the dropzone area for uploading files. +- **`onFileDelete`** (optional): A function to be executed when a file is deleted. + +## Usage + +```tsx +import { ImageField } from 'ggf-ui'; +``` + +```tsx + +``` + +## Storybook + +[https://661f5982ddc662c8c9a12d6b-fqsleqszgq.chromatic.com/?path=/story/inputs-imagefield--example&globals=backgrounds.value:!hex(333333)]() diff --git a/docs/InputField.mdx b/docs/InputField.mdx new file mode 100644 index 0000000..7e1a9ff --- /dev/null +++ b/docs/InputField.mdx @@ -0,0 +1,71 @@ +## Title + +InputField + +## Description + +The InputField component provides a versatile input field with customizable options such as label, type, color, error visibility, length limits, and password visibility toggle. It is designed to seamlessly integrate with forms and handle various input types including text, email, and password. + +## Installation + +**optional** + +```bash +npm i zod @hookform/resolvers +``` + +## Library + +- react-hook-form `<=^7.51.3` +- zod, @hookform/resolvers (optional) + +## Anatomy + +- **`name`**: The unique identifier for the input field. +- **`label`** (optional): The label displayed above the input field. +- **`type`** (optional): Specifies the type of input field. It can be `'text' | 'email' | 'password'`. Defaults to `'text'`. +- **`color`** (optional): Specifies the color theme of the input field. It can be `'yellow' | 'purple'`. Defaults to `'purple'`. +- **`isErrorVisible`** (optional): A boolean indicating whether the error message should be visible. Defaults to `false`. +- **`isLimited`** (optional): A boolean indicating whether the input length is limited. Defaults to `false`. +- **`isDisabled`** (optional): A boolean indicating whether the input field should be disabled. Defaults to `false`. +- **`maxLength`** (optional): The maximum length allowed for input. Defaults to `10`. +- **`minLength`** (optional): The minimum length required for input. Defaults to `1`. +- **`readOnly`** (optional): A boolean indicating whether the input field should be read-only. Defaults to `false`. +- **`autoComplete`** (optional): Specifies whether the browser should automatically complete the input value. Can be `'on' | 'off'`. Defaults to `'on'`. + +## Usage + +```tsx +import { InputField } from 'ggf-ui'; +import { FormProvider, useForm } from 'react-hook-form'; +import { zodResolver } from '@hookform/resolvers/zod'; // optional +import { z } from 'zod'; // optional +``` + +```tsx +const Schema = z.object({ + InputField: z.string().min(1), +}); // optional + +const methods = useForm({ + mode: 'all', + resolver: zodResolver(Schema), // optional +}); + +const onSubmit = (data: object) => { + console.log(data); +}; + +return ( + +
+ + + +
+); +``` + +## UI + + diff --git a/docs/InputRadio.mdx b/docs/InputRadio.mdx new file mode 100644 index 0000000..9e61f84 --- /dev/null +++ b/docs/InputRadio.mdx @@ -0,0 +1,66 @@ +## Title + +InputRadio + +## Description + +The InputRadio component provides a set of radio buttons for selecting a single option from a list. It allows users to choose from a predefined set of options and captures the selected value for form submission or data processing. + +## Library + +- react-hook-form `<=^7.51.3` + +## Anatomy + +- **`formMethod`**: An object containing the form methods provided by React Hook Form, including the register function. +- **`label`**: The label displayed above the radio button group. +- **`name`**: The unique identifier for the radio button group. +- **`radioList`**: An array of objects representing each radio button option. Each object contains: + - **`id`**: The unique identifier for the radio button. + - **`value`**: The value associated with the radio button. + - **`label`**: The text label displayed next to the radio button. +- **`defaultCheckIndex`** (optional): The index of the option in the radioList array that should be checked by default. Defaults to `0`. +- **`color`** (optional): Specifies the color theme of the radio buttons. It can be `'yellow' | 'purple'`. Defaults to `'purple'`. +- **`onClick`** (optional): A function called when a radio button is clicked. It receives the value of the selected option as a parameter. + +## Usage + +```tsx +import { InputRadio } from 'ggf-ui'; +import { FormProvider, useForm } from 'react-hook-form'; +``` + +```tsx +const methods = useForm({ + mode: 'all', +}); + +const onSubmit = (data: object) => { + console.log(data); +}; + +return ( + +
+ onClick(value)} + /> + + +
+); +``` + +## UI + + diff --git a/docs/SearchBar.mdx b/docs/SearchBar.mdx new file mode 100644 index 0000000..7f431c1 --- /dev/null +++ b/docs/SearchBar.mdx @@ -0,0 +1,28 @@ +## Title + +SearchBar + +## Description + +The SearchBar component provides a search input field with an accompanying search icon for users to enter search queries. It allows users to input text and trigger a search action by pressing the Enter key or clicking the search icon. + +## Anatomy + +- **`placeholder`**: The placeholder text displayed in the search input field. +- **`onChange`**: A function called whenever the value in the search input field changes. It receives the new value as a parameter. +- **`color`** (optional): Specifies the color theme of the search input field. It can be `'yellow' | 'purple'`. Defaults to `'purple'`. +- **`maxLength`** (optional): The maximum number of characters allowed in the search input field. Defaults to `20`. + +## Usage + +```tsx +import { SearchBar } from 'ggf-ui'; +``` + +```tsx + onChange(value)} color='purple' maxLength={20} /> +``` + +## Storybook + +[https://661f5982ddc662c8c9a12d6b-fqsleqszgq.chromatic.com/?path=/story/inputs-searchbar--example&globals=backgrounds.value:!hex(333333)]() diff --git a/docs/TextField.mdx b/docs/TextField.mdx new file mode 100644 index 0000000..02b1c1c --- /dev/null +++ b/docs/TextField.mdx @@ -0,0 +1,63 @@ +## Title + +TextField + +## Description + +The TextField component provides a customizable input field for users to enter text. It supports various features such as labeling, character length limits, and error handling. + +## Anatomy + +- **`formMethod`**: An object containing methods and state from React Hook Form library. + - **`register`**: A function to register the input field with React Hook Form. + - **`formState`**: An object representing the state of the form. + - **`watch`**: A function to watch for changes in the input field. +- **`name`**: The name of the input field. +- **`label`** (optional): The label text associated with the input field. +- **`minLength`** (optional): The minimum number of characters allowed in the input field. +- **`maxLength`** (optional): The maximum number of characters allowed in the input field. +- **`placeholder`** (optional): The placeholder text displayed in the input field when it's empty. +- **`color`** (optional): Specifies the color theme of the input field. Options include `'yellow' | 'purple'`. Defaults to `'purple'`. + +## Usage + +```tsx +import { TextField } from 'ggf-ui'; +import { FormProvider, useForm } from 'react-hook-form'; +``` + +```tsx +const Schema = z.object({ + TextField: z.string().min(1), +}); // optional + +const methods = useForm({ + mode: 'all', + resolver: zodResolver(Schema), // optional +}); + +const onSubmit = (data: object) => { + console.log(data); +}; + +return ( + +
+ + + +
+); +``` + +## UI + + diff --git a/package.json b/package.json index 765395d..5e8a684 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ggf-ui", - "version": "0.2.8", + "version": "0.3.0", "description": "GGF design system library", "private": false, "type": "module",