npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

intelligent-dag-select

v0.7.6

Published

React DAG select component based on [intelligent-tree-select](https://github.com/lecbyjak/intelligent-tree-select) which is based on [react-select](https://github.com/JedWatson/react-select#react-select) and [react-virtualized-select](https://github.com/b

Downloads

45

Readme

Intelligent-DAG-Select

React DAG select component based on intelligent-tree-select which is based on react-select and react-virtualized-select

Intelligent-DAG-Select is a modified version of intelligent-tree-select that uses DAG as input data and renders it as a tree. Thus, some subtrees may occur multiple times in the tree.

Before start

Before you can use this component you will need Node.js in version 6.5+, but i recommend to use the latest available version.

Getting started

Easiest way is to install via NPM

npm install intelligent-dag-select --save

Then import it

import { DagSelect } from 'intelligent-dag-select'
import { TreeSelect } from 'intelligent-dag-select'
import 'bootstrap/dist/css/bootstrap.css';
import "intelligent-dag-select/lib/styles.css"

example of the usage in the src/demo.js

Components

  • VirtualizedTreeSelect provides a list select.
  • ExpandableTreeSelect adds an expand button to each item in the list.
  • TreeSelect adds an option to load data using the fetchOptions function, that returns either a list of new items or a Promise of the new items.
  • DagSelect adds a "DAG to Tree" conversion adding items to the list so that it can handle duplicate items and cycles.

Virtualized tree select Props

Props types are same as the one introduced by [email protected] The additional parameters introduced by virtualized-tree-select are optional. They are:

| Property | Type | Default Value | Description | |:---|:---|:---|:---| | childrenKey | string | 'children' | path of the child value in option objects | | expanded | bool | false | whether the options are expanded by default | | isMenuOpen | bool | false | Whether the menu is open. Setting this to true force menu to me always opened | | maxHeight | number | 300 | Maximum height of the dropdown menu | | minHeight | number | 0 | Minimum height of the dropdown menu | | menuRenderer | func | - | overriding built-in drop-down menu render function | | optionRenderer | func | - | overriding built-in option render function. | | optionHeight | number or func | 25px | Option height. Dynamic height can be supported via a function with the signature ({ option: Object }): number | | optionLeftOffset | number | 16px | Option base left offset. Left offset is calculated as depth level of the option * optionLeftOffset | | renderAsTree | bool | true | whether options should be rendered as a tree. |

Custom Option Renderer

You can override the built-in option renderer by specifying your own optionRenderer property. Your renderer should return a React element that represents the specified option. It will be passed the following named parameters:

| Property | Type | Description | |:---|:---|:---| | childrenKey | string | Attribute of option that contains the children key. | | focusedOption | Object | The option currently-focused in the dropdown. Use this property to determine if your rendered option should be highlighted or styled differently. | | focusedOptionIndex | number | Index of the currently-focused option. | | focusOption | Function | Callback to update the focused option; for example, you may want to call this function on mouse-over. | | key | string | A unique identifier for each element created by the renderer. | | labelKey | string | Attribute of option that contains the display text. | | option | Object | The option to be rendered. | | optionIndex | number | Index of the option to be rendered. | | renderAsTree | bool | Whether the options should be render as a tree. | | searchString | string | Current content of the search input. | | selectValue | Function | Callback to update the selected values; for example, you may want to call this function on click. | | optionStyle | Object | Styles that must be passed to the rendered option. These styles are specifying the position of each option (required for correct option displaying in the dropdown). | toggleOption | Function | Expand/Collapse option if it has children. | | valueArray | Array<Object> | Array of the currently-selected options. Use this property to determine if your rendered option should be highlighted or styled differently. | | valueKey | string | Attribute of option that contains the value. |

Intelligent tree select props

| Property | Type | Default Value | Description | |:---|:---|:---|:---| | displayInfoOnHover | bool | false | Whether to render option information on hover. By default, this info is extracted by transforming the option to JSON and stringifying it. | | tooltipKey | string | -- | Attribute of option which will be used as content of hover tooltip (instead of stringified option itself). | | labelValue | func | -- | Return the label for option. Function with signature ({ option: Object }): string | | onOptionCreate | function | -- | callback when the new option is created. Signature ({ option: Object}): none| | optionLifetime | string | '5m' | String representing how long the options should be cached. Syntax: XdXhXmXs where X is some number, d stands for days, h hours ,m minutes, s seconds| | showSettings | bool | 'true' | whether the section with settings and button for creating new option should be visible| | simpleTreeData | bool | true | whether the options are in the simple format. (One node == one option) | | fetchOptions | func | -- | Signature: ({searchString, optionID, limit, offset, option}): Promise. If the optionID is not an empty string then the function should return children options of that option (option is provided as well should it be needed). If the searchString is not an empty string then the function should return all options whose label value match the searchStromg + their parent options| | fetchLimit | number | 100 | amount of data to be fetched | | multi | bool | true | whether the select in multi select or not | | name | string | -- | Unique name for the component. Whenever this prop is set then the options will be cached| | formComponent | func | -- | Function returning React element representing form. Syntax ({onOptionCreate, toggleModal, options, labelKey, valueKey, childrenKey}): React.component|

IntelligentTreeSelect public API

| Method | Description | |:---|:---| | resetOptions | Force reloading of options when fetchOptions property is used to specify how to load options. If options are specified in props, this reloads them from the current props. |