Giter Club home page Giter Club logo

simformsolutionspvtltd / react-native-tree-selection Goto Github PK

View Code? Open in Web Editor NEW
44.0 3.0 3.0 12.71 MB

A high-performance and lightweight tree selection library for React Native🎖

License: MIT License

Shell 0.30% JavaScript 2.93% Starlark 0.95% Java 24.72% CMake 0.43% C++ 11.55% Ruby 2.61% Objective-C 3.78% Objective-C++ 7.04% TypeScript 45.69%
component dropdown library react-native select selection tree-select tree-selection tree-structure typescript

react-native-tree-selection's Introduction

Tree-Selection

react-native-tree-selection

react-native-tree-selection on npm react-native-tree-selection downloads react-native-tree-selection install size Android iOS MIT


Hierarchical Tree Select Control, a high-performance and lightweight library designed to effortlessly render select components with hierarchical tree data. This versatile control not only facilitates the display of work selection but also empowers users to make their own selection.

It is simple to use and fully customizable. It works on both android and iOS platforms.


🎬 Preview


Tree Selection with No Children Tree Selection with children
Tree Selection with no Children Tree Selection with children

Quick Access

Getting Started 🔧

Installation

1. Install library
npm install react-native-tree-selection
--- or ---
yarn add react-native-tree-selection
2. Install cocoapods in the ios project
cd ios && pod install

Tree-selection

Tree Data Format

const treeData: TreeDataTypes[] = [
  {
    id: '1',
    title: 'Fruits',
    data: [
      {
        title: 'Apples',
        data: [
          {
            title: 'Red Delicious',
          },
          {
            title: 'Granny Smith',
          },
          {
            title: 'Gala',
          },
        ],
      },
      {
        title: 'Bananas',
        data: [
          {
            title: 'Cavendish',
          },
          {
            title: 'Lady Finger',
          },
        ],
      },
    ],
  },
];

Usage

<TreeSelect
  data={treeData}
  childKey="data"
  titleKey="title"
  onParentPress={onParentPress}
  onChildPress={onChildPress}
  onCheckBoxPress={onCheckBoxPress}
/>

Checkout TreeSelect Example here

App
import React from 'react';
import { TreeDataTypes, TreeSelect } from 'react-native-tree-selection';

const App = () => {
  return (
    <TreeSelect
      data={treeData}
      childKey="data"
      titleKey="title"
      onParentPress={onParentPress}
      onChildPress={onChildPress}
      onCheckBoxPress={onCheckBoxPress}
    />
  );
};

export default App;

Properties


Prop Default Type Description
data - Data An array of objects representing multiple data items organized in a tree structure. Each object can contain various types of data and can be extended to include additional information. This format allows for flexible data manipulation and integration.
childKey data string Specifies the name of the property in each node object that contains the children to display.
titleKey title string Specifies the name of the property in each node object that contains the title to display.
onParentPress - function A callback function that is called when a parent node is clicked.
onChildPress - function A callback function that is called when a child node is clicked.
onCheckBoxPress - function A callback function that is called when a checkbox is clicked.
rightIconStyles - ImageStyle Checkbox image style
leftIconStyles - ImageStyle Arrow image style
parentContainerStyles - ViewStyle Style for Parent Container
childContainerStyles - TextStyle Style for Child Container
parentTextStyles - TextStyle Text Styles for Parent
childTextStyles - TextStyle Text Styles for Child
touchableActiveOpacity 0.7 activeOpacity activeOpacity style for Touchable.
flatListProps - FlatListProps<ArrayData> Provide FlatList props.
autoSelectParents true Boolean Parents will gets selected when all the children are selected.
autoSelectChildren true Boolean Children will gets selected when parent is selected.
renderArrowOpen - ImagePropType Change icon for Arrow when parent expands.
renderArrowClosed - ImagePropType Change icon for checkbox when checkbox is selected.
renderSelect - ImagePropType Change icon for checkbox when checkbox is selected.
renderUnSelect - ImagePropType Change icon for checkbox when checkbox is unselected.

Example

A full working example project is here Example

yarn
yarn example ios   // For ios
yarn example android   // For Android

TODO

  • Provide dynamic render items

Find this library useful? ❤️

Support it by joining stargazers for this repository.⭐

Bugs / Feature requests / Feedbacks

For bugs, feature requests, and discussion please use GitHub Issues, GitHub New Feature, GitHub Feedback

🤝 How to Contribute

We'd love to have you improve this library or fix a problem 💪 Check out our Contributing Guide for ideas on contributing.

Awesome Mobile Libraries

License

react-native-tree-selection's People

Contributors

devesh-g-simformsolutions avatar mukesh-simform avatar shalin-simform avatar simform-solutions avatar vikrant-k-simformsolutions avatar virajpsimformsolutions avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-tree-selection's Issues

[FEATURE]:Request new functionality

Sorry for creating this issue, I'm pretty happy with the library as it stands, but I'd like you to add one more feature: When I select all the children, I should return only the array containing the parent object in the onCheckBoxPress event.
Sorry, the above text is translated by translation software

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.