@doramart/virtual-tree-select-shared
v0.1.0
Published
Shared utilities and types for virtual-tree-select
Maintainers
Readme
@virtual-tree-select/shared
Shared utilities and types for virtual-tree-select components
📦 Overview
This package contains shared utilities, types, and helper functions used by both @virtual-tree-select/vue3 and @virtual-tree-select/vue2 packages.
Note: This is an internal dependency package. You typically don't need to install it directly. It will be automatically installed when you install either the Vue 3 or Vue 2 package.
🔧 Installation
If you need to use the utilities directly:
npm install @virtual-tree-select/sharedOr using yarn:
yarn add @virtual-tree-select/sharedOr using pnpm:
pnpm add @virtual-tree-select/shared📚 Exported Utilities
Tree Utilities
flattenTree- Flatten tree structure to arrayfindNode- Find node by keygetNodePath- Get path from root to nodefilterTree- Filter tree by predicateexpandNode- Expand node and its ancestorscollapseNode- Collapse node and its descendants
Type Definitions
TreeNode- Tree node interfaceFlatNode- Flattened node interfaceTreeSelectProps- Component props interfaceTreeSelectEmits- Component emits interface
Constants
DEFAULT_FIELD_NAMES- Default field name mappingsKEY_CODES- Keyboard key codes
💡 Usage Example
import { flattenTree, findNode, type TreeNode } from '@virtual-tree-select/shared';
const treeData: TreeNode[] = [
{
key: '1',
title: 'Node 1',
children: [
{ key: '1-1', title: 'Child 1-1' },
{ key: '1-2', title: 'Child 1-2' },
],
},
];
// Flatten tree
const flatNodes = flattenTree(treeData);
// Find node
const node = findNode(treeData, '1-1');⚠️ Important Notes
- This package is designed to be used internally by the Vue 3 and Vue 2 packages
- Direct usage is not recommended unless you're building custom tree components
- The API may change between minor versions
- For normal usage, install
@virtual-tree-select/vue3or@virtual-tree-select/vue2instead
📖 Documentation
- API Documentation - Complete API reference
- Main Repository - Source code and examples
🔗 Related Packages
- @virtual-tree-select/vue3 - Vue 3 version
- @virtual-tree-select/vue2 - Vue 2.6 version
🤝 Contributing
Contributions are welcome! Please read our Contributing Guide for details.
