1.0.9 • Published 1 year ago

inputs-checkbox-toggle v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

inputs show toggle with CheckBox

Description

This package provides a toggle checkbox component for React applications. It allows you to show or hide input fields, enhancing the user experience by providing a cleaner UI. The code used in the demonstration GIF can be found in the 'Usage' section.

Installation

just run this command and see the example

npm i inputs-checkbox-toggle

Requirements

  • React 15.0.0 or higher

Usage

After installing the package, you can import it into your project and use it to create a toggle checkbox. for a basic example look at: this simple example

Props

Here's a Markdown table describing the props, types, and functionalities of the useSelectFieldHook function:

FunctionDescription
useSelectFieldHook(fields: Field[])A custom React hook that manages the state of selected fields and provides functions to handle selection changes.
Parameters
fieldsAn array of objects representing the initial state of selected fields. Each object maps field names to boolean values indicating whether the field is selected.
ReturnsAn object containing various state variables and functions to interact with the selection state.
Returned Object
selectedFieldsState variable holding the current selection state of fields.
setSelectedFieldsFunction to update the state of selected fields.
isHidden(label: string)Function to determine if a field with a given label is hidden (not selected).
selectAllCheckedState variable indicating whether the "select all" checkbox is checked.
setSelectAllCheckedFunction to update the state of the "select all" checkbox.
selectAllChange(data: any)Function triggered when the "select all" checkbox is toggled. Updates the selected fields state based on the new state of the "select all" checkbox.
selectChange(value: string, checked: boolean)Function triggered when an individual checkbox is toggled. Updates the selected fields state based on the checkbox value and checked state.
checkboxDataAn array containing data for each checkbox, including label, value, and checked state.

This table provides an overview of the useSelectFieldHook function, its parameters, returned object, and the functionalities it offers.

CheckboxGroup accepts the following props, all of which can be obtained from the useSelectFieldHook:

PropTypeDescriptionDefault Value
data{ label: string; value: string; checked: boolean }[]An array of objects, each representing a checkbox. Each object should have a label (the text displayed next to the checkbox), a value (the value of the checkbox), and a checked (a boolean indicating whether the checkbox is checked).-
onChange(value: string, checked: boolean) => voidA function that is called when a checkbox is toggled. It receives the value of the checkbox and a boolean checked indicating the new state of the checkbox.-
selectAllbooleanA boolean indicating whether a "select all" checkbox should be displayed.false
selectAllCheckedbooleanA boolean indicating whether the "select all" checkbox is checked.false
labelstringThe label for the checkbox group.'Select All'
classNamestringA CSS class to apply to the checkbox group.''
oneCheckBoxStylestringA CSS class to apply to each individual checkbox.''
selectAllChange(data: { label: string; value: string; checked: boolean }[]) => voidA function that is called when the "select all" checkbox is toggled. It receives the new state of all checkboxes.-

Contributing

Contributions are always welcome! Here's how you can help:

  • Reporting bugs: If you find a bug, please open an issue on our GitHub issue tracker. Describe the problem and include steps to reproduce it, if possible.

  • Suggesting enhancements: If you have an idea for a new feature or an improvement to an existing feature, please open an issue to discuss it.

  • Submitting pull requests: If you've fixed a bug or implemented a new feature, we'd love to see your work. Please submit a pull request with your changes.

1.0.9

1 year ago

1.0.8

1 year ago

1.0.2

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago