0.1.6 • Published 6 years ago

react-finderjs v0.1.6

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

react-finderjs

React componet wrapper for https://mynameistechno.github.io/finderjs/ javascript component

Installation

npm install --save react-finderjs

Usage

import * as ReactFinder from "react-finderjs";

const data = [
  {
    id: 1,
    label: 'Label A'
    children: [
      {
        id: 10,
        label: 'Label A1'
      },
      {
        id: 11,
        label: 'Label A2'
      }
    ]
  }, {
    id: 2,
    label: 'Label B'
  }
];

<ReactFinder
  className = ""
  data = {data} />
ParameterTypeDescription
classNamestringCustom class name for the wrapping div
createItemContentFunctionDefine how each item is rendered. Parameters (config, item). The first parameter passed in is the config object and the second is the item object that is currently being iterated on. It should return an HTML Element.
dataArrayData source is a array of objects
disableAutoScrollBooleanDisable automatically scrolling to newly created column on parent click (default: false)
onItemSelectedFunctionCallback function when item selected. Parameters: (item, domItem)
onLeafSelectedFunctionCallback function when leaf node selected. Parameters: (item)
onColumnCreatedFunctionCallback function when column is created. Parameters: (domColumn)
valueObjectCurrently selected value. The id property is required for data lookup.

Data

Each item in the array itself should be an object. Each object that doesn't contain a children property is considered a leaf node. When a leaf node is selected, the onLeafSelected event will be emitted. When present, the value of the children property should be an array. When a node has children and it is selected, it will use the children to populate the next column.

Notes

If an object has a url property it will be treated slightly differently: the anchor tag that wraps the item will have the href attribute assigned to it. Upon selection of this item the browser will be redirected to the provided URL.

Events

react-finderjs has a few events you can provide callbacks for, as well as some public methods to trigger events in the native finderjs library:

Property CallbackDescription
onItemSelectedAn item was selected (clicked or keyboard arrow)
onLeafSelectedA leaf node was selected
onColumnCreatedA column was appended to the container
Public EventDescription
createColumnAppend a column to the container
navigateNavigate the finder by going up, down, right, or left

Project commands

CommandDescription
npm run buildBuild /dist finderjs
npm run cleanDeletes /dist folder for build
npm run publishRun clean & build commands
npm run testRun test (not completed)
npm run watchRun watch for file changes
0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

7 years ago

0.1.0

7 years ago

1.0.0

7 years ago