Skip to content

Commit ac89c4c

Browse files
committed
feat: Ability to have default values ✨ (#96)
1 parent 3cb2c3c commit ac89c4c

File tree

15 files changed

+1252
-1698
lines changed

15 files changed

+1252
-1698
lines changed

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,18 @@ Data for rendering the tree select items. The object requires the following stru
216216

217217
```js
218218
{
219-
label, // required: Checkbox label
220-
value, // required: Checkbox value
221-
children, // optional: Array of child objects
222-
checked, // optional: Initial state of checkbox. if true, checkbox is selected and corresponding pill is rendered.
223-
disabled, // optional: Selectable state of checkbox. if true, the checkbox is disabled and the node is not selectable.
224-
expanded, // optional: If true, the node is expanded (children of children nodes are not expanded by default unless children nodes also have expanded: true).
225-
className, // optional: Additional css class for the node. This is helpful to style the nodes your way
226-
tagClassName, // optional: Css class for the corresponding tag. Use this to add custom style the pill corresponding to the node.
227-
actions, // optional: An array of extra action on the node (such as displaying an info icon or any custom icons/elements)
228-
dataset, // optional: Allows data-* attributes to be set on the node and tag elements
229-
... // optional: Any extra properties that you'd like to receive during `onChange` event
219+
label, // required: Checkbox label
220+
value, // required: Checkbox value
221+
children, // optional: Array of child objects
222+
checked, // optional: Initial state of checkbox. if true, checkbox is selected and corresponding pill is rendered.
223+
disabled, // optional: Selectable state of checkbox. if true, the checkbox is disabled and the node is not selectable.
224+
expanded, // optional: If true, the node is expanded (children of children nodes are not expanded by default unless children nodes also have expanded: true).
225+
className, // optional: Additional css class for the node. This is helpful to style the nodes your way
226+
tagClassName, // optional: Css class for the corresponding tag. Use this to add custom style the pill corresponding to the node.
227+
actions, // optional: An array of extra action on the node (such as displaying an info icon or any custom icons/elements)
228+
dataset, // optional: Allows data-* attributes to be set on the node and tag elements
229+
isDefaultValue, // optional: Indicate if a node is a default value. When true, the dropdown will automatically select the node(s) when there is no other selected node. Can be used on more than one node.
230+
... // optional: Any extra properties that you'd like to receive during `onChange` event
230231
}
231232
```
232233

@@ -434,6 +435,8 @@ npm lint // fixes anything that can be fixed and reports remaining errors
434435
npm run test:cov // test coverage
435436
```
436437

438+
**Note:** If your browser doesn't hot reload or reflect changes during `npm run demo`, then delete `docs/bundle.js` and try again. Before submitting final PR, run `npm run build:docs` to build the bundle.js file again.
439+
437440
## License
438441

439442
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)

docs/bundle.js

Lines changed: 1 addition & 1250 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<!DOCTYPE html>
22
<html>
33

4-
<head>
5-
<title>React Dropdown Tree Select Demo</title>
6-
<link rel="stylesheet" href="./index.css" />
7-
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
8-
crossorigin="anonymous">
9-
</head>
4+
<head>
5+
<title>React Dropdown Tree Select Demo</title>
6+
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
7+
crossorigin="anonymous">
8+
</head>
109

11-
<body>
12-
<div id="app"></div>
13-
<script src="bundle.js"></script>
14-
</body>
10+
<body>
11+
<div id="app"></div>
12+
<script src="bundle.js"></script>
13+
</body>
1514

1615
</html>

docs/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import HOCReadme from './stories/HOCReadme'
66
import Readme from './stories/Readme'
77
import Simple from './stories/Simple'
88
import Options from './stories/Options'
9+
import DefaultValues from './stories/DefaultValues'
910

1011
import './stories/utils/prism.css'
1112

@@ -15,6 +16,7 @@ const stories = [
1516

1617
{ name: 'Basic (no extra styles)', component: Simple },
1718
{ name: 'Options', component: Options },
19+
{ name: 'Default Values', component: DefaultValues },
1820
{ name: 'With Bootstrap Styles', component: CodeSandbox('382pjronm') },
1921
{ name: 'With Material Design Styles', component: CodeSandbox('2o1pv6925p') },
2022
{ name: 'With Country flags', component: CodeSandbox('6w41wlvj8z') },

0 commit comments

Comments
 (0)