feat(@clayui/nav): add new composition to Vertical Nav with collection API and adds new expandedKeys
API
#5526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #5515
This PR makes a lot of changes, first we are rewriting the
VerticalNav
component to use the Collection API and exposing a new public<VerticalNav.Item />
component.We are also adding a new
expandedKeys
API with the pattern of controlled and uncontrolled, this makes it easier to manage this state for items in the tree like implementing expand all or collapse.We are also moving the implementation of all this to the
@clayui/core
package and the@clayui/nav
package just keeps backwards compatibility with the old version of the component and possibility to use the new version when declaring the new composition.With the Collection implementation I needed to rewrite the component and this brings a new composition with the benefits of the Collection pattern.
This brings new possibilities to the component as it is also data agnostic and does not depend on a data structure to force the product to follow. As I said, we still maintain compatibility with the previous version, so it's easy to migrate to use the new composition and the new features that Collection brings, also the
expandedKeys
API will only take effect with the new composition because it depends on which keys in the tree is unique. Consuming the component directly from the@clayui/core
package will only support the new composition.ToDo