From 0773b66654fc91b67f8b83a7d4fe2a4b79961a51 Mon Sep 17 00:00:00 2001 From: Hrusikesh Panda Date: Sat, 17 Mar 2018 23:43:53 -0400 Subject: [PATCH] fix: Update doc site with updated readme :books: --- docs/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/bundle.js b/docs/bundle.js index a1d94e48..1b1c4b2f 100644 --- a/docs/bundle.js +++ b/docs/bundle.js @@ -993,7 +993,7 @@ eval("/* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var __W /* 135 */ /***/ (function(module, exports) { -eval("module.exports = \"# react-dropdown-tree-select\\r\\n\\r\\n---\\r\\n\\r\\n[![NPM version][npm-image]][npm-url] [![gzip][gzip-image]][gzip-url] [![npm download][download-image]][npm-url]\\r\\n\\r\\n[![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![semantic-release][semantic-release]][semantic-release-url] [![Commitizen friendly][commitizen]][commitizen-url] [![Greenkeeper badge][greenkeeper]][greenkeeper-url]\\r\\n\\r\\n[npm-image]: http://img.shields.io/npm/v/react-dropdown-tree-select.svg?style=flat-square\\r\\n[npm-url]: http://npmjs.org/package/react-dropdown-tree-select\\r\\n[travis-image]: https://img.shields.io/travis/dowjones/react-dropdown-tree-select.svg?style=flat-square\\r\\n[travis-url]: https://travis-ci.org/dowjones/react-dropdown-tree-select\\r\\n[coveralls-image]: https://img.shields.io/coveralls/dowjones/react-dropdown-tree-select.svg?style=flat-square\\r\\n[coveralls-url]: https://coveralls.io/r/dowjones/react-dropdown-tree-select?branch=master\\r\\n[download-image]: https://img.shields.io/npm/dm/react-dropdown-tree-select.svg?style=flat-square\\r\\n[semantic-release]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square\\r\\n[semantic-release-url]: https://github.com/semantic-release/semantic-release\\r\\n[commitizen]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square\\r\\n[commitizen-url]: http://commitizen.github.io/cz-cli/\\r\\n[greenkeeper]: https://badges.greenkeeper.io/dowjones/react-dropdown-tree-select.svg?style=flat-square\\r\\n[greenkeeper-url]: https://greenkeeper.io/\\r\\n[gzip-image]: http://img.badgesize.io/https://unpkg.com/react-dropdown-tree-select/dist/react-dropdown-tree-select.js?compression=gzip&style=flat-square\\r\\n[gzip-url]: https://unpkg.com/react-dropdown-tree-select/dist/react-dropdown-tree-select.js\\r\\n\\r\\n## React Dropdown Tree Select\\r\\n\\r\\nA lightweight and fast control to render a select component that can display hierarchical tree data. In addition, the control shows the selection in pills and allows user to search the options for quick filtering and selection.\\r\\n\\r\\n## Table of Contents\\r\\n\\r\\n* [Screenshot](#screenshot)\\r\\n* [Demo](#example)\\r\\n * [Vanilla (no framework)](#vanilla-no-framework)\\r\\n * [With Bootstrap](#with-bootstrap)\\r\\n * [With Material Design](#with-material-design)\\r\\n * [As Single Select](#as-single-select)\\r\\n* [Install](#install)\\r\\n * [Peer Dependencies](#peer-dependencies)\\r\\n* [Usage](#usage)\\r\\n* [Props](#props)\\r\\n * [className](#classname)\\r\\n * [onChange](#onchange)\\r\\n * [onNodeToggle](#onnodetoggle)\\r\\n * [data](#data)\\r\\n * [placeholderText](#placeholdertext)\\r\\n * [keepTreeOnSearch](#keeptreeonsearch)\\r\\n* [Styling and Customization](#styling-and-customization)\\r\\n * [Using default styles](#default-styles)\\r\\n * [Customizing with Bootstrap, Material Design styles](#customizing-styles)\\r\\n* [Performance](#performance)\\r\\n * [Search optimizations](#search-optimizations)\\r\\n * [Search debouncing](#search-debouncing)\\r\\n * [Virtualized rendering](#virtualized-rendering)\\r\\n * [Reducing costly DOM manipulations](#reducing-costly-dom-manipulations)\\r\\n* [FAQ](#faq)\\r\\n* [Doing more with HOCs](/docs/HOC.md)\\r\\n* [Development](#development)\\r\\n* [License](#license)\\r\\n\\r\\n## Screenshot\\r\\n\\r\\n![animated demo screenshot](https://user-images.githubusercontent.com/781818/37562235-0ae9e9ec-2a3a-11e8-8266-b0e6b716d0d1.gif)\\r\\n\\r\\n## Demo\\r\\n\\r\\n##### Vanilla, no framework\\r\\n\\r\\nOnline demo: https://dowjones.github.io/react-dropdown-tree-select/#/story/with-vanilla-styles\\r\\n\\r\\n##### With Bootstrap\\r\\n\\r\\nOnline demo: https://dowjones.github.io/react-dropdown-tree-select/#/story/with-bootstrap-styles\\r\\n\\r\\n##### With Material Design\\r\\n\\r\\nOnline demo: https://dowjones.github.io/react-dropdown-tree-select/#/story/with-material-design-styles\\r\\n\\r\\n##### As Single Select\\r\\n\\r\\nOnline demo: https://dowjones.github.io/react-dropdown-tree-select/#/story/simple-select\\r\\n\\r\\n## Install\\r\\n\\r\\n```\\r\\n> npm i react-dropdown-tree-select\\r\\n\\r\\n// or if using yarn\\r\\n\\r\\n> yarn add react-dropdown-tree-select\\r\\n```\\r\\n\\r\\n### Peer Dependencies\\r\\n\\r\\nIn order to avoid version conflicts in your project, you must specify and install [react](https://www.npmjs.com/package/react), [react-dom](https://www.npmjs.com/package/react-dom) as [peer dependencies](https://nodejs.org/en/blog/npm/peer-dependencies/). Note that NPM doesn't install peer dependencies automatically. Instead it will show you a warning message with instructions on how to install them.\\r\\n\\r\\n## Usage\\r\\n\\r\\n```jsx\\r\\nimport React from 'react'\\r\\nimport ReactDOM from 'react-dom'\\r\\nimport DropdownTreeSelect from 'react-dropdown-tree-select'\\r\\n\\r\\nconst tree = {\\r\\n label: 'search me',\\r\\n value: 'searchme',\\r\\n children: [\\r\\n {\\r\\n label: 'search me too',\\r\\n value: 'searchmetoo',\\r\\n children: [\\r\\n {\\r\\n label: 'No one can get me',\\r\\n value: 'anonymous'\\r\\n }\\r\\n ]\\r\\n }\\r\\n ]\\r\\n}\\r\\n\\r\\nconst onChange = (currentNode, selectedNodes) => {\\r\\n console.log('onChange::', currentNode, selectedNodes)\\r\\n}\\r\\nconst onAction = ({ action, node }) => {\\r\\n console.log(`onAction:: [${action}]`, node)\\r\\n}\\r\\nconst onNodeToggle = currentNode => {\\r\\n console.log('onNodeToggle::', currentNode)\\r\\n}\\r\\n\\r\\nReactDOM.render(\\r\\n ,\\r\\n document.body\\r\\n) // in real world, you'd want to render to an element, instead of body.\\r\\n```\\r\\n\\r\\n## Props\\r\\n\\r\\n### className\\r\\n\\r\\nType: `string`\\r\\n\\r\\nAdditional classname for container. The container renders with a default classname of `react-dropdown-tree-select`.\\r\\n\\r\\n### onChange\\r\\n\\r\\nType: `function`\\r\\n\\r\\nFires when a node change event occurs. Currently the following actions trigger a node change:\\r\\n\\r\\n* Checkbox click which checks/unchecks the item\\r\\n* Closing of pill (which unchecks the corresponding checkbox item)\\r\\n\\r\\nCalls the handler with the current node object and all selected nodes (if any). Example:\\r\\n\\r\\n```jsx\\r\\nfunction onChange(currentNode, selectedNodes) {\\r\\n // currentNode: { label, value, children, expanded, checked, className, ...extraProps }\\r\\n // selectedNodes: [{ label, value, children, expanded, checked, className, ...extraProps }]\\r\\n}\\r\\n\\r\\nreturn \\r\\n```\\r\\n\\r\\n### onNodeToggle\\r\\n\\r\\nType: `function`\\r\\n\\r\\nFires when a node is expanded or collapsed.\\r\\n\\r\\nCalls the handler with the current node object. Example:\\r\\n\\r\\n```jsx\\r\\nfunction onNodeToggle(currentNode) {\\r\\n // currentNode: { label, value, children, expanded, checked, className, ...extraProps }\\r\\n}\\r\\n\\r\\nreturn \\r\\n```\\r\\n\\r\\n### data\\r\\n\\r\\nType: `Object` or `Array`\\r\\n\\r\\nData for rendering the tree select items. The object requires the following structure:\\r\\n\\r\\n```js\\r\\n{\\r\\n label, // required: Checkbox label\\r\\n value, // required: Checkbox value\\r\\n children, // optional: Array of child objects\\r\\n checked, // optional: Initial state of checkbox. if true, checkbox is selected and corresponding pill is rendered.\\r\\n disabled, // optional: Selectable state of checkbox. if true, the checkbox is disabled and the node is not selectable.\\r\\n expanded, // optional: If true, the node is expanded (children of children nodes are not expanded by default unless children nodes also have expanded: true).\\r\\n className, // optional: Additional css class for the node. This is helpful to style the nodes your way\\r\\n tagClassName, // optional: Css class for the corresponding tag. Use this to add custom style the pill corresponding to the node.\\r\\n actions, // optional: An array of extra action on the node (such as displaying an info icon or any custom icons/elements)\\r\\n dataset, // optional: Allows data-* attributes to be set on the node and tag elements\\r\\n ... // optional: Any extra properties that you'd like to receive during `onChange` event\\r\\n}\\r\\n```\\r\\n\\r\\nThe `action` object requires the following structure:\\r\\n\\r\\n```js\\r\\n{\\r\\n className, // required: CSS class for the node. e.g. `fa fa-info`\\r\\n onAction, // required: Fired on click of the action. The event handler receives `action` object as well as the `node` object.\\r\\n title, // optional: HTML tooltip text\\r\\n text, // optional: Any text to be displayed. This is helpful to pass ligatures if you're using ligature fonts\\r\\n ... // optional: Any extra properties that you'd like to receive during `onChange` event\\r\\n}\\r\\n```\\r\\n\\r\\nAn array renders a tree with multiple root level items whereas an object renders a tree with a single root element (e.g. a `Select All` root node).\\r\\n\\r\\n### placeholderText\\r\\n\\r\\nType: `string`\\r\\n\\r\\nThe text to display as placeholder on the search box. Defaults to `Choose...`\\r\\n\\r\\n### keepTreeOnSearch\\r\\n\\r\\nType: `bool`\\r\\n\\r\\nDisplays search results as a tree instead of flattened results\\r\\n\\r\\n### simpleSelect\\r\\n\\r\\nType: `bool` (default: `false`)\\r\\n\\r\\nTurns the dropdown into a simple, single select dropdown. If you pass tree data, only immediate children are picked, grandchildren nodes are ignored. Defaults to `false`.\\r\\n\\r\\n## Styling and Customization\\r\\n\\r\\n### Default styles\\r\\n\\r\\nThe component brings minimal styles for bare-bones functional rendering. It is kept purposefully minimal so that user can style/customize it completely to suit their needs.\\r\\n\\r\\n#### Using WebPack\\r\\n\\r\\nIf you're using a bundler like webpack, make sure you configure webpack to import the default styles. To do so, simply add this rule to your webpack config:\\r\\n\\r\\n```js\\r\\n// allow webpack to import/bundle styles from node_modules for this component\\r\\nmodule: {\\r\\n rules: [\\r\\n {\\r\\n test: /\\\\.css$/,\\r\\n use: ExtractTextPlugin.extract({\\r\\n fallback: 'style-loader',\\r\\n use: [\\r\\n {\\r\\n loader: 'css-loader'\\r\\n }\\r\\n ]\\r\\n }),\\r\\n include: /node_modules[/\\\\\\\\]react-dropdown-tree-select/\\r\\n }\\r\\n ]\\r\\n}\\r\\n```\\r\\n\\r\\n#### Using a CDN\\r\\n\\r\\nYou can import and place a style link directly by referencing it from a CDN.\\r\\n\\r\\n```html\\r\\n\\r\\n```\\r\\n\\r\\nNote: Above example will always fetch the latest version. To fetch a specific version, use `https://unpkg.com/react-dropdown-tree-select@/dist/styles.css`. Visit [unpkg.com](https://unpkg.com/#/) to see other options.\\r\\n\\r\\n#### Using with other bundlers\\r\\n\\r\\nYou can reference the files from `node_modules/react-dropdown-tree-select/dist/styles.css` to include in your own bundle via gulp or any other bundlers you have.\\r\\n\\r\\n### Customizing styles\\r\\n\\r\\nOnce you import default styles, it is easy to add/override the provided styles to match popular frameworks. Checkout `/docs` folder for some examples.\\r\\n\\r\\n* [With Bootstrap](/docs/examples/bootstrap)\\r\\n* [With Material Design ](/docs/examples/material)\\r\\n\\r\\n## Performance\\r\\n\\r\\n### Search optimizations\\r\\n\\r\\n* The tree creates a flat list of nodes from hierarchical tree data to perform searches that are linear in time irrespective of the tree depth or size.\\r\\n* It also memoizes each search term, so subsequent searches are instantaneous (almost).\\r\\n* Last but not the least, the search employs progressive filtering technique where subsequent searches are performed on the previous search set. E.g., say the tree has 4000 nodes altogether and the user wants to filter nodes that contain the text: \\\"2002\\\". As the user enters each key press the search goes like this:\\r\\n\\r\\n```\\r\\nkey press : 2-----20-----200-----2002\\r\\n | | | |\\r\\nsearch set: 967 834 49 7\\r\\n```\\r\\n\\r\\nThe search for \\\"20\\\" happens against the previously matched set of 967 as opposed to all 4000 nodes; \\\"200\\\" happens against 834 nodes and so on.\\r\\n\\r\\n### Search debouncing\\r\\n\\r\\nThe tree debounces key presses to avoid costly search calculations. The default duration is 100ms.\\r\\n\\r\\n### Virtualized rendering\\r\\n\\r\\nThe dropdown renders only visible content and skips any nodes that are going to hidden from the user. E.g., if a parent node is not expanded, there is no point in rendering children since they will not be visible anyway.\\r\\n\\r\\nPlanned feature: Use [react-virtualized](https://github.com/bvaughn/react-virtualized) to take this to the next level.\\r\\n\\r\\n### Reducing costly DOM manipulations\\r\\n\\r\\nThe tree tries to minimize the DOM manipulations as much as possible. E.g., during searching, the non-matching nodes are simply `hidden` and css adjusted on remaining to create the perception of a new filtered list.\\r\\nNode toggling also achieves the expand/collapse effect by manipulating css classes instead of creating new tree with filtered out nodes.\\r\\n\\r\\n## FAQ\\r\\n\\r\\n### How do I change the placeholder text?\\r\\n\\r\\nThe default [placeholder](#placeholdertext) is `Choose...`. If you want to change this to something else, you can use `placeholderText` property to set it.\\r\\n\\r\\n```jsx\\r\\n\\r\\n```\\r\\n\\r\\n### How do I tweak styles?\\r\\n\\r\\nEasy style customization is one of the design goals of this component. Every visual aspect of this dropdown can be tweaked without going through extensive hacks. E.g., to change how disabled nodes appear:\\r\\n\\r\\n```css\\r\\n.node .fa-ban {\\r\\n color: #ccc;\\r\\n}\\r\\n```\\r\\n\\r\\nThe css classes needed to overide can be found by inspecting the component via developer tools (chrome/safari/ie) or firebug (firefox). You can also inspect the [source code](/src) or look in [examples](/docs/index.css).\\r\\n\\r\\n### I do not want the default styles, do I need to fork the project?\\r\\n\\r\\nAbsolutely not! Simply do not import the styles (webpack) or include it in your html (link tags). Roughly, this is the HTML/CSS skeleton rendered by the component:\\r\\n\\r\\n```pug\\r\\ndiv.react-dropdown-tree-select\\r\\n div.dropdown\\r\\n a.dropdown-trigger\\r\\n span\\r\\n ul.tag-list\\r\\n li.tag-item\\r\\n input\\r\\n div.dropdown-content\\r\\n ul.root\\r\\n li.node.tree\\r\\n i.toggle.collapsed\\r\\n label\\r\\n input.checkbox-item\\r\\n span.node-label\\r\\n```\\r\\n\\r\\nWrite your own styles from scratch or copy [existing styles](https://github.com/search?utf8=%E2%9C%93&q=repo%3Adowjones%2Freact-dropdown-tree-select+language%3ACSS+path%3A%2Fsrc&type=Code&ref=advsearch&l=CSS&l=) and tweak them.\\r\\nThen include your own custom styles in your project.\\r\\n\\r\\n:bulb: Pro tip: Leverage [node's](#data) `className`, `tagClassName` or [action's](#data) `className` prop to emit your own class name. Then override/add css propeties in your class. Remember that last person wins in CSS (unless specificity or `!important` is involved). Often times, this may suffice and may be easier then writing all the styles from the ground up.\\r\\n\\r\\nIf you believe this aspect can be improved further, feel free to raise an issue.\\r\\n\\r\\n### My question is not listed here\\r\\n\\r\\nFind more questions and their answers in the [issue tracker](https://github.com/dowjones/react-dropdown-tree-select/issues?utf8=%E2%9C%93&q=%20label%3Aquestion%20). If it still doesn't answer your questions, please raise an issue.\\r\\n\\r\\n## Development\\r\\n\\r\\nClone the git repo and install dependencies.\\r\\n\\r\\n```\\r\\nnpm i\\r\\n\\r\\n// or\\r\\n\\r\\nyarn install\\r\\n```\\r\\n\\r\\nYou can then run following scripts for local development\\r\\n\\r\\n```\\r\\nnpm run demo // local demo, watches and rebuilds on changes\\r\\n\\r\\nnpm test // test your changes\\r\\n\\r\\nnpm lint // fixes anything that can be fixed and reports remaining errors\\r\\n\\r\\nnpm run test:cov // test coverage\\r\\n```\\r\\n\\r\\n## License\\r\\n\\r\\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)\\r\\n\\r\\nReleased 2017 by [Hrusikesh Panda](https://github.com/mrchief) @ [Dow Jones](https://github.com/dowjones)\\r\\n\"\n\n//////////////////\n// WEBPACK FOOTER\n// ./README.md\n// module id = 135\n// module chunks = 0\n\n//# sourceURL=webpack:///./README.md?"); +eval("module.exports = \"# react-dropdown-tree-select\\r\\n\\r\\n---\\r\\n\\r\\n[![NPM version][npm-image]][npm-url] [![gzip][gzip-image]][gzip-url] [![npm download][download-image]][npm-url]\\r\\n\\r\\n[![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![semantic-release][semantic-release]][semantic-release-url] [![Commitizen friendly][commitizen]][commitizen-url] [![Greenkeeper badge][greenkeeper]][greenkeeper-url]\\r\\n\\r\\n[npm-image]: http://img.shields.io/npm/v/react-dropdown-tree-select.svg?style=flat-square\\r\\n[npm-url]: http://npmjs.org/package/react-dropdown-tree-select\\r\\n[travis-image]: https://img.shields.io/travis/dowjones/react-dropdown-tree-select.svg?style=flat-square\\r\\n[travis-url]: https://travis-ci.org/dowjones/react-dropdown-tree-select\\r\\n[coveralls-image]: https://img.shields.io/coveralls/dowjones/react-dropdown-tree-select.svg?style=flat-square\\r\\n[coveralls-url]: https://coveralls.io/r/dowjones/react-dropdown-tree-select?branch=master\\r\\n[download-image]: https://img.shields.io/npm/dm/react-dropdown-tree-select.svg?style=flat-square\\r\\n[semantic-release]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square\\r\\n[semantic-release-url]: https://github.com/semantic-release/semantic-release\\r\\n[commitizen]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square\\r\\n[commitizen-url]: http://commitizen.github.io/cz-cli/\\r\\n[greenkeeper]: https://badges.greenkeeper.io/dowjones/react-dropdown-tree-select.svg?style=flat-square\\r\\n[greenkeeper-url]: https://greenkeeper.io/\\r\\n[gzip-image]: http://img.badgesize.io/https://unpkg.com/react-dropdown-tree-select/dist/react-dropdown-tree-select.js?compression=gzip&style=flat-square\\r\\n[gzip-url]: https://unpkg.com/react-dropdown-tree-select/dist/react-dropdown-tree-select.js\\r\\n\\r\\n## React Dropdown Tree Select\\r\\n\\r\\nA lightweight and fast control to render a select component that can display hierarchical tree data. In addition, the control shows the selection in pills and allows user to search the options for quick filtering and selection.\\r\\n\\r\\n## Table of Contents\\r\\n\\r\\n* [Screenshot](#screenshot)\\r\\n* [Demo](#example)\\r\\n * [Vanilla (no framework)](#vanilla-no-framework)\\r\\n * [With Bootstrap](#with-bootstrap)\\r\\n * [With Material Design](#with-material-design)\\r\\n * [As Single Select](#as-single-select)\\r\\n* [Install](#install)\\r\\n * [Peer Dependencies](#peer-dependencies)\\r\\n* [Usage](#usage)\\r\\n* [Props](#props)\\r\\n * [className](#classname)\\r\\n * [onChange](#onchange)\\r\\n * [onNodeToggle](#onnodetoggle)\\r\\n * [data](#data)\\r\\n * [placeholderText](#placeholdertext)\\r\\n * [keepTreeOnSearch](#keeptreeonsearch)\\r\\n * [simpleSelect](#simpleselect)\\r\\n* [Styling and Customization](#styling-and-customization)\\r\\n * [Using default styles](#default-styles)\\r\\n * [Customizing with Bootstrap, Material Design styles](#customizing-styles)\\r\\n* [Performance](#performance)\\r\\n * [Search optimizations](#search-optimizations)\\r\\n * [Search debouncing](#search-debouncing)\\r\\n * [Virtualized rendering](#virtualized-rendering)\\r\\n * [Reducing costly DOM manipulations](#reducing-costly-dom-manipulations)\\r\\n* [FAQ](#faq)\\r\\n* [Doing more with HOCs](/docs/HOC.md)\\r\\n* [Development](#development)\\r\\n* [License](#license)\\r\\n\\r\\n## Screenshot\\r\\n\\r\\n![animated demo screenshot](https://user-images.githubusercontent.com/781818/37562235-0ae9e9ec-2a3a-11e8-8266-b0e6b716d0d1.gif)\\r\\n\\r\\n## Demo\\r\\n\\r\\n##### Vanilla, no framework\\r\\n\\r\\nOnline demo: https://dowjones.github.io/react-dropdown-tree-select/#/story/with-vanilla-styles\\r\\n\\r\\n##### With Bootstrap\\r\\n\\r\\nOnline demo: https://dowjones.github.io/react-dropdown-tree-select/#/story/with-bootstrap-styles\\r\\n\\r\\n##### With Material Design\\r\\n\\r\\nOnline demo: https://dowjones.github.io/react-dropdown-tree-select/#/story/with-material-design-styles\\r\\n\\r\\n##### As Single Select\\r\\n\\r\\nOnline demo: https://dowjones.github.io/react-dropdown-tree-select/#/story/simple-select\\r\\n\\r\\n## Install\\r\\n\\r\\n```\\r\\n> npm i react-dropdown-tree-select\\r\\n\\r\\n// or if using yarn\\r\\n\\r\\n> yarn add react-dropdown-tree-select\\r\\n```\\r\\n\\r\\n### Peer Dependencies\\r\\n\\r\\nIn order to avoid version conflicts in your project, you must specify and install [react](https://www.npmjs.com/package/react), [react-dom](https://www.npmjs.com/package/react-dom) as [peer dependencies](https://nodejs.org/en/blog/npm/peer-dependencies/). Note that NPM doesn't install peer dependencies automatically. Instead it will show you a warning message with instructions on how to install them.\\r\\n\\r\\n## Usage\\r\\n\\r\\n```jsx\\r\\nimport React from 'react'\\r\\nimport ReactDOM from 'react-dom'\\r\\nimport DropdownTreeSelect from 'react-dropdown-tree-select'\\r\\n\\r\\nconst tree = {\\r\\n label: 'search me',\\r\\n value: 'searchme',\\r\\n children: [\\r\\n {\\r\\n label: 'search me too',\\r\\n value: 'searchmetoo',\\r\\n children: [\\r\\n {\\r\\n label: 'No one can get me',\\r\\n value: 'anonymous'\\r\\n }\\r\\n ]\\r\\n }\\r\\n ]\\r\\n}\\r\\n\\r\\nconst onChange = (currentNode, selectedNodes) => {\\r\\n console.log('onChange::', currentNode, selectedNodes)\\r\\n}\\r\\nconst onAction = ({ action, node }) => {\\r\\n console.log(`onAction:: [${action}]`, node)\\r\\n}\\r\\nconst onNodeToggle = currentNode => {\\r\\n console.log('onNodeToggle::', currentNode)\\r\\n}\\r\\n\\r\\nReactDOM.render(\\r\\n ,\\r\\n document.body\\r\\n) // in real world, you'd want to render to an element, instead of body.\\r\\n```\\r\\n\\r\\n## Props\\r\\n\\r\\n### className\\r\\n\\r\\nType: `string`\\r\\n\\r\\nAdditional classname for container. The container renders with a default classname of `react-dropdown-tree-select`.\\r\\n\\r\\n### onChange\\r\\n\\r\\nType: `function`\\r\\n\\r\\nFires when a node change event occurs. Currently the following actions trigger a node change:\\r\\n\\r\\n* Checkbox click which checks/unchecks the item\\r\\n* Closing of pill (which unchecks the corresponding checkbox item)\\r\\n\\r\\nCalls the handler with the current node object and all selected nodes (if any). Example:\\r\\n\\r\\n```jsx\\r\\nfunction onChange(currentNode, selectedNodes) {\\r\\n // currentNode: { label, value, children, expanded, checked, className, ...extraProps }\\r\\n // selectedNodes: [{ label, value, children, expanded, checked, className, ...extraProps }]\\r\\n}\\r\\n\\r\\nreturn \\r\\n```\\r\\n\\r\\n### onNodeToggle\\r\\n\\r\\nType: `function`\\r\\n\\r\\nFires when a node is expanded or collapsed.\\r\\n\\r\\nCalls the handler with the current node object. Example:\\r\\n\\r\\n```jsx\\r\\nfunction onNodeToggle(currentNode) {\\r\\n // currentNode: { label, value, children, expanded, checked, className, ...extraProps }\\r\\n}\\r\\n\\r\\nreturn \\r\\n```\\r\\n\\r\\n### data\\r\\n\\r\\nType: `Object` or `Array`\\r\\n\\r\\nData for rendering the tree select items. The object requires the following structure:\\r\\n\\r\\n```js\\r\\n{\\r\\n label, // required: Checkbox label\\r\\n value, // required: Checkbox value\\r\\n children, // optional: Array of child objects\\r\\n checked, // optional: Initial state of checkbox. if true, checkbox is selected and corresponding pill is rendered.\\r\\n disabled, // optional: Selectable state of checkbox. if true, the checkbox is disabled and the node is not selectable.\\r\\n expanded, // optional: If true, the node is expanded (children of children nodes are not expanded by default unless children nodes also have expanded: true).\\r\\n className, // optional: Additional css class for the node. This is helpful to style the nodes your way\\r\\n tagClassName, // optional: Css class for the corresponding tag. Use this to add custom style the pill corresponding to the node.\\r\\n actions, // optional: An array of extra action on the node (such as displaying an info icon or any custom icons/elements)\\r\\n dataset, // optional: Allows data-* attributes to be set on the node and tag elements\\r\\n ... // optional: Any extra properties that you'd like to receive during `onChange` event\\r\\n}\\r\\n```\\r\\n\\r\\nThe `action` object requires the following structure:\\r\\n\\r\\n```js\\r\\n{\\r\\n className, // required: CSS class for the node. e.g. `fa fa-info`\\r\\n onAction, // required: Fired on click of the action. The event handler receives `action` object as well as the `node` object.\\r\\n title, // optional: HTML tooltip text\\r\\n text, // optional: Any text to be displayed. This is helpful to pass ligatures if you're using ligature fonts\\r\\n ... // optional: Any extra properties that you'd like to receive during `onChange` event\\r\\n}\\r\\n```\\r\\n\\r\\nAn array renders a tree with multiple root level items whereas an object renders a tree with a single root element (e.g. a `Select All` root node).\\r\\n\\r\\n### placeholderText\\r\\n\\r\\nType: `string`\\r\\n\\r\\nThe text to display as placeholder on the search box. Defaults to `Choose...`\\r\\n\\r\\n### keepTreeOnSearch\\r\\n\\r\\nType: `bool`\\r\\n\\r\\nDisplays search results as a tree instead of flattened results\\r\\n\\r\\n### simpleSelect\\r\\n\\r\\nType: `bool` (default: `false`)\\r\\n\\r\\nTurns the dropdown into a simple, single select dropdown. If you pass tree data, only immediate children are picked, grandchildren nodes are ignored. Defaults to `false`.\\r\\n\\r\\n## Styling and Customization\\r\\n\\r\\n### Default styles\\r\\n\\r\\nThe component brings minimal styles for bare-bones functional rendering. It is kept purposefully minimal so that user can style/customize it completely to suit their needs.\\r\\n\\r\\n#### Using WebPack\\r\\n\\r\\nIf you're using a bundler like webpack, make sure you configure webpack to import the default styles. To do so, simply add this rule to your webpack config:\\r\\n\\r\\n```js\\r\\n// allow webpack to import/bundle styles from node_modules for this component\\r\\nmodule: {\\r\\n rules: [\\r\\n {\\r\\n test: /\\\\.css$/,\\r\\n use: ExtractTextPlugin.extract({\\r\\n fallback: 'style-loader',\\r\\n use: [\\r\\n {\\r\\n loader: 'css-loader'\\r\\n }\\r\\n ]\\r\\n }),\\r\\n include: /node_modules[/\\\\\\\\]react-dropdown-tree-select/\\r\\n }\\r\\n ]\\r\\n}\\r\\n```\\r\\n\\r\\n#### Using a CDN\\r\\n\\r\\nYou can import and place a style link directly by referencing it from a CDN.\\r\\n\\r\\n```html\\r\\n\\r\\n```\\r\\n\\r\\nNote: Above example will always fetch the latest version. To fetch a specific version, use `https://unpkg.com/react-dropdown-tree-select@/dist/styles.css`. Visit [unpkg.com](https://unpkg.com/#/) to see other options.\\r\\n\\r\\n#### Using with other bundlers\\r\\n\\r\\nYou can reference the files from `node_modules/react-dropdown-tree-select/dist/styles.css` to include in your own bundle via gulp or any other bundlers you have.\\r\\n\\r\\n### Customizing styles\\r\\n\\r\\nOnce you import default styles, it is easy to add/override the provided styles to match popular frameworks. Checkout `/docs` folder for some examples.\\r\\n\\r\\n* [With Bootstrap](/docs/examples/bootstrap)\\r\\n* [With Material Design ](/docs/examples/material)\\r\\n\\r\\n## Performance\\r\\n\\r\\n### Search optimizations\\r\\n\\r\\n* The tree creates a flat list of nodes from hierarchical tree data to perform searches that are linear in time irrespective of the tree depth or size.\\r\\n* It also memoizes each search term, so subsequent searches are instantaneous (almost).\\r\\n* Last but not the least, the search employs progressive filtering technique where subsequent searches are performed on the previous search set. E.g., say the tree has 4000 nodes altogether and the user wants to filter nodes that contain the text: \\\"2002\\\". As the user enters each key press the search goes like this:\\r\\n\\r\\n```\\r\\nkey press : 2-----20-----200-----2002\\r\\n | | | |\\r\\nsearch set: 967 834 49 7\\r\\n```\\r\\n\\r\\nThe search for \\\"20\\\" happens against the previously matched set of 967 as opposed to all 4000 nodes; \\\"200\\\" happens against 834 nodes and so on.\\r\\n\\r\\n### Search debouncing\\r\\n\\r\\nThe tree debounces key presses to avoid costly search calculations. The default duration is 100ms.\\r\\n\\r\\n### Virtualized rendering\\r\\n\\r\\nThe dropdown renders only visible content and skips any nodes that are going to hidden from the user. E.g., if a parent node is not expanded, there is no point in rendering children since they will not be visible anyway.\\r\\n\\r\\nPlanned feature: Use [react-virtualized](https://github.com/bvaughn/react-virtualized) to take this to the next level.\\r\\n\\r\\n### Reducing costly DOM manipulations\\r\\n\\r\\nThe tree tries to minimize the DOM manipulations as much as possible. E.g., during searching, the non-matching nodes are simply `hidden` and css adjusted on remaining to create the perception of a new filtered list.\\r\\nNode toggling also achieves the expand/collapse effect by manipulating css classes instead of creating new tree with filtered out nodes.\\r\\n\\r\\n## FAQ\\r\\n\\r\\n### How do I change the placeholder text?\\r\\n\\r\\nThe default [placeholder](#placeholdertext) is `Choose...`. If you want to change this to something else, you can use `placeholderText` property to set it.\\r\\n\\r\\n```jsx\\r\\n\\r\\n```\\r\\n\\r\\n### How do I tweak styles?\\r\\n\\r\\nEasy style customization is one of the design goals of this component. Every visual aspect of this dropdown can be tweaked without going through extensive hacks. E.g., to change how disabled nodes appear:\\r\\n\\r\\n```css\\r\\n.node .fa-ban {\\r\\n color: #ccc;\\r\\n}\\r\\n```\\r\\n\\r\\nThe css classes needed to overide can be found by inspecting the component via developer tools (chrome/safari/ie) or firebug (firefox). You can also inspect the [source code](/src) or look in [examples](/docs/index.css).\\r\\n\\r\\n### I do not want the default styles, do I need to fork the project?\\r\\n\\r\\nAbsolutely not! Simply do not import the styles (webpack) or include it in your html (link tags). Roughly, this is the HTML/CSS skeleton rendered by the component:\\r\\n\\r\\n```pug\\r\\ndiv.react-dropdown-tree-select\\r\\n div.dropdown\\r\\n a.dropdown-trigger\\r\\n span\\r\\n ul.tag-list\\r\\n li.tag-item\\r\\n input\\r\\n div.dropdown-content\\r\\n ul.root\\r\\n li.node.tree\\r\\n i.toggle.collapsed\\r\\n label\\r\\n input.checkbox-item\\r\\n span.node-label\\r\\n```\\r\\n\\r\\nWrite your own styles from scratch or copy [existing styles](https://github.com/search?utf8=%E2%9C%93&q=repo%3Adowjones%2Freact-dropdown-tree-select+language%3ACSS+path%3A%2Fsrc&type=Code&ref=advsearch&l=CSS&l=) and tweak them.\\r\\nThen include your own custom styles in your project.\\r\\n\\r\\n:bulb: Pro tip: Leverage [node's](#data) `className`, `tagClassName` or [action's](#data) `className` prop to emit your own class name. Then override/add css propeties in your class. Remember that last person wins in CSS (unless specificity or `!important` is involved). Often times, this may suffice and may be easier then writing all the styles from the ground up.\\r\\n\\r\\nIf you believe this aspect can be improved further, feel free to raise an issue.\\r\\n\\r\\n### My question is not listed here\\r\\n\\r\\nFind more questions and their answers in the [issue tracker](https://github.com/dowjones/react-dropdown-tree-select/issues?utf8=%E2%9C%93&q=%20label%3Aquestion%20). If it still doesn't answer your questions, please raise an issue.\\r\\n\\r\\n## Development\\r\\n\\r\\nClone the git repo and install dependencies.\\r\\n\\r\\n```\\r\\nnpm i\\r\\n\\r\\n// or\\r\\n\\r\\nyarn install\\r\\n```\\r\\n\\r\\nYou can then run following scripts for local development\\r\\n\\r\\n```\\r\\nnpm run demo // local demo, watches and rebuilds on changes\\r\\n\\r\\nnpm test // test your changes\\r\\n\\r\\nnpm lint // fixes anything that can be fixed and reports remaining errors\\r\\n\\r\\nnpm run test:cov // test coverage\\r\\n```\\r\\n\\r\\n## License\\r\\n\\r\\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)\\r\\n\\r\\nReleased 2017 by [Hrusikesh Panda](https://github.com/mrchief) @ [Dow Jones](https://github.com/dowjones)\\r\\n\"\n\n//////////////////\n// WEBPACK FOOTER\n// ./README.md\n// module id = 135\n// module chunks = 0\n\n//# sourceURL=webpack:///./README.md?"); /***/ }), /* 136 */