A select input for tree shaped data.
npm install --save react-breadcrumb-select
import React from "react";
import ReactDOM from "react-dom";
import BreadcrumbSelect from "react-breadcrumb-select";
const data = [
{
id: 1,
name: '',
parent: null,
children: [
{
id: 3,
name: 'three',
parent: 1,
chlidren: [
{
id: 5,
name: 'five',
parent: 3,
children: []
}
]
},
{
id: 4,
name: 'four',
parent: 1,
chlidren: [
{
id: 6,
name: 'six',
parent: 4,
children: []
}
]
}
]
},
{
id: 2,
name: 'two',
parent: null,
chlidren: []
}
];
function Example() {
const handleChange = e => {
// Do some stuff...
};
return (
<div>
<BreadcrumbSelect data={data} onChange={handleChange} />
</div>
);
}
const app = document.getElementById("app");
ReactDOM.render(<Example />, app);
PropTypes.arrayOf(PropTypes.object)
or PropTypes.object
Required
PropTypes.string
Select input plceholder text.
PropTypes.number
Id of the selected element. It will display the tree of selects.
PropTypes.func
Callback function when an element is selected.
PropTypes.string
Text to display when the search in a select input returns no results.
PropTypes.arrayOf(PropTypes.number)
Array of ids to disable. Elements will appear but with a disabled state.
PropTypes.shape({
id: PropTypes.number,
name: PropTypes.string,
parent: PropTypes.number,
children: PropTypes.arrayOf(PropTypes.object) // or null
})