// Utils
import { createNamespace, addUnit, isDef } from '../utils';
// Components
import Icon from '../icon';
import Sidebar from '../sidebar';
import SidebarItem from '../sidebar-item';
const [createComponent, bem] = createNamespace('tree-select');
export default createComponent({
props: {
max: {
type: [Number, String],
default: Infinity,
},
items: {
type: Array,
default: () => [],
},
height: {
type: [Number, String],
default: 300,
},
activeId: {
type: [Number, String, Array],
default: 0,
},
selectedIcon: {
type: String,
default: 'success',
},
mainActiveIndex: {
type: [Number, String],
default: 0,
},
},
emits: [
'click-nav',
'click-item',
'update:activeId',
'update:mainActiveIndex',
],
setup(props, { emit, slots }) {
return function () {
const { items, height, activeId, selectedIcon, mainActiveIndex } = props;
const selectedItem = items[+mainActiveIndex] || {};
const subItems = selectedItem.children || [];
const isMultiple = Array.isArray(activeId);
function isActiveItem(id) {
return isMultiple ? activeId.indexOf(id) !== -1 : activeId === id;
}
const Navs = items.map((item) => (