dipson88 / treeselectjs

Treeselect on vanilla JS
MIT License
83 stars 15 forks source link

Add property to allow specific groups to be opened/closed by default and add option to have tags count include count of children #93

Open ForbiddenEra opened 8 months ago

ForbiddenEra commented 8 months ago

Hi,

This is actually potentially useful as a file selector and I'm trying to use it as such.

It'd be great if I could add a property so that certain groups (directories in my case) are open/closed by default. For example, in my case it's used with an HTML input with webkitdirectory to allow devs to upload source, would be great to be able to have groups expanded to a certain point (which is already doable of course) but also have groups for directories like .git or node_modules specifically not ever pre-expanded.

It'd also be great if the tags count could optionally include all children, if I set tagsCountText to "file(s) selected" it shows up like "3 file(s) selected" if 3 groups (directories) are selected but that ignores any tags/entries (files) in each group.

Thanks!

ForbiddenEra commented 8 months ago

I was able to 'emulate' the files selected functionality by overwriting the element immediately after running new Treeselect() and also within the input event/inputCallback:

After new Treeselect():

document.querySelector('.treeselect-input__tags-count').innerHTML = `${ev.target.files.length} file(s) selected`;

and inputCallback:

inputCallback: (x)=>{
    document.querySelector('.treeselect-input__tags-count').innerHTML = `${x.length} file(s) selected`;
},