v-float 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +223 -204
- package/dist/composables/index.d.ts +1 -3
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/interactions/index.d.ts +0 -2
- package/dist/composables/interactions/index.d.ts.map +1 -1
- package/dist/composables/interactions/polygon.d.ts +2 -2
- package/dist/composables/interactions/polygon.d.ts.map +1 -1
- package/dist/composables/interactions/use-click.d.ts +2 -2
- package/dist/composables/interactions/use-click.d.ts.map +1 -1
- package/dist/composables/interactions/use-escape-key.d.ts +2 -2
- package/dist/composables/interactions/use-escape-key.d.ts.map +1 -1
- package/dist/composables/interactions/use-focus.d.ts +30 -25
- package/dist/composables/interactions/use-focus.d.ts.map +1 -1
- package/dist/composables/interactions/use-hover.d.ts +2 -2
- package/dist/composables/interactions/use-hover.d.ts.map +1 -1
- package/dist/composables/middlewares/arrow.d.ts +1 -2
- package/dist/composables/middlewares/arrow.d.ts.map +1 -1
- package/dist/composables/middlewares/index.d.ts +3 -1
- package/dist/composables/middlewares/index.d.ts.map +1 -1
- package/dist/composables/positioning/index.d.ts +5 -0
- package/dist/composables/positioning/index.d.ts.map +1 -0
- package/dist/composables/positioning/use-arrow.d.ts.map +1 -0
- package/dist/composables/{interactions → positioning}/use-client-point.d.ts +2 -2
- package/dist/composables/positioning/use-client-point.d.ts.map +1 -0
- package/dist/composables/positioning/use-floating-tree.d.ts +240 -0
- package/dist/composables/positioning/use-floating-tree.d.ts.map +1 -0
- package/dist/composables/{use-floating.d.ts → positioning/use-floating.d.ts} +19 -10
- package/dist/composables/positioning/use-floating.d.ts.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +84 -7
- package/dist/utils.d.ts.map +1 -1
- package/dist/v-float.es.js +1732 -1620
- package/dist/v-float.umd.js +1 -1
- package/package.json +73 -76
- package/dist/composables/interactions/use-client-point.d.ts.map +0 -1
- package/dist/composables/interactions/utils/browser-detection.d.ts +0 -23
- package/dist/composables/interactions/utils/browser-detection.d.ts.map +0 -1
- package/dist/composables/interactions/utils/element-detection.d.ts +0 -53
- package/dist/composables/interactions/utils/element-detection.d.ts.map +0 -1
- package/dist/composables/interactions/utils/event-utils.d.ts +0 -30
- package/dist/composables/interactions/utils/event-utils.d.ts.map +0 -1
- package/dist/composables/interactions/utils/index.d.ts +0 -11
- package/dist/composables/interactions/utils/index.d.ts.map +0 -1
- package/dist/composables/interactions/utils/tree-context.d.ts +0 -32
- package/dist/composables/interactions/utils/tree-context.d.ts.map +0 -1
- package/dist/composables/use-arrow.d.ts.map +0 -1
- package/dist/composables/use-floating-tree.d.ts +0 -110
- package/dist/composables/use-floating-tree.d.ts.map +0 -1
- package/dist/composables/use-floating.d.ts.map +0 -1
- /package/dist/composables/{use-arrow.d.ts → positioning/use-arrow.d.ts} +0 -0
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
import { AnchorElement, FloatingContext, FloatingElement, UseFloatingOptions } from './use-floating';
|
|
3
|
-
/**
|
|
4
|
-
* Options for creating a TreeNode
|
|
5
|
-
*/
|
|
6
|
-
export interface CreateTreeNodeOptions {
|
|
7
|
-
/** Optional ID for the node. If not provided, one will be generated. */
|
|
8
|
-
id?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Options for configuring tree behavior
|
|
12
|
-
*/
|
|
13
|
-
export interface CreateTreeOptions {
|
|
14
|
-
/** Strategy for deleting child nodes when a parent is deleted.
|
|
15
|
-
* - 'orphan': Children are detached from the tree (parent becomes null).
|
|
16
|
-
* - 'recursive': Children are also deleted recursively.
|
|
17
|
-
* @default 'recursive'
|
|
18
|
-
*/
|
|
19
|
-
deleteStrategy?: "orphan" | "recursive";
|
|
20
|
-
}
|
|
21
|
-
export interface TreeNode<T> {
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly data: T;
|
|
24
|
-
readonly parent: Ref<TreeNode<T> | null>;
|
|
25
|
-
readonly children: Ref<TreeNode<T>[]>;
|
|
26
|
-
readonly isRoot: boolean;
|
|
27
|
-
readonly isLeaf: Readonly<Ref<boolean>>;
|
|
28
|
-
addChild: (childNode: TreeNode<T>) => void;
|
|
29
|
-
_removeChildInstance: (childNode: TreeNode<T>) => boolean;
|
|
30
|
-
findChild: (predicate: (node: TreeNode<T>) => boolean) => TreeNode<T> | null;
|
|
31
|
-
findDescendant: (predicate: (node: TreeNode<T>) => boolean) => TreeNode<T> | null;
|
|
32
|
-
isDescendantOf: (potentialAncestor: TreeNode<T>) => boolean;
|
|
33
|
-
getPath: () => TreeNode<T>[];
|
|
34
|
-
}
|
|
35
|
-
export interface Tree<T> {
|
|
36
|
-
readonly root: TreeNode<T>;
|
|
37
|
-
readonly nodeMap: Readonly<Map<string, TreeNode<T>>>;
|
|
38
|
-
findNodeById: (id: string) => TreeNode<T> | null;
|
|
39
|
-
addNode: (data: T, parentId?: string | null, nodeOptions?: CreateTreeNodeOptions) => TreeNode<T> | null;
|
|
40
|
-
removeNode: (nodeId: string, deleteStrategy?: "orphan" | "recursive") => boolean;
|
|
41
|
-
moveNode: (nodeId: string, newParentId: string | null) => boolean;
|
|
42
|
-
traverse: (strategy?: "dfs" | "bfs", startNode?: TreeNode<T> | null) => TreeNode<T>[];
|
|
43
|
-
dispose: () => void;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Configuration options for the floating tree
|
|
47
|
-
*/
|
|
48
|
-
export interface FloatingTreeOptions extends CreateTreeOptions {
|
|
49
|
-
}
|
|
50
|
-
export interface UseFloatingTreeReturn extends Omit<Tree<FloatingContext>, "addNode"> {
|
|
51
|
-
addNode: (anchorEl: Ref<AnchorElement>, floatingEl: Ref<FloatingElement>, options?: UseFloatingOptions) => TreeNode<FloatingContext> | null;
|
|
52
|
-
getAllOpenNodes: () => TreeNode<FloatingContext>[];
|
|
53
|
-
getTopmostOpenNode: () => TreeNode<FloatingContext> | null;
|
|
54
|
-
/**
|
|
55
|
-
* Executes a provided function once for each tree node that matches the specified relationship.
|
|
56
|
-
* This is a flexible iteration method that can target nodes based on their relationship to a target node.
|
|
57
|
-
*
|
|
58
|
-
* @param nodeId - The ID of the target node used as a reference point for the relationship
|
|
59
|
-
* @param callback - A function to execute for each matching node
|
|
60
|
-
* @param options - Configuration options for the iteration behavior
|
|
61
|
-
*/
|
|
62
|
-
applyToNodes: (nodeId: string, callback: (node: TreeNode<FloatingContext>) => void, options?: {
|
|
63
|
-
relationship?: NodeRelationship;
|
|
64
|
-
applyToMatching?: boolean;
|
|
65
|
-
}) => void;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Predefined node relationship strategies used for filtering nodes.
|
|
69
|
-
*/
|
|
70
|
-
type NodeRelationship = "ancestors-only" | "siblings-only" | "descendants-only" | "children-only" | "self-and-ancestors" | "self-and-children" | "self-and-descendants" | "self-and-siblings" | "self-ancestors-and-children" | "full-branch" | "all-except-branch";
|
|
71
|
-
/**
|
|
72
|
-
* Creates and manages a hierarchical tree of floating elements.
|
|
73
|
-
*
|
|
74
|
-
* @param anchorEl - The anchor element for the root floating context
|
|
75
|
-
* @param floatingEl - The floating element for the root floating context
|
|
76
|
-
* @param options - Options for the root floating context
|
|
77
|
-
* @param treeOptions - Options for tree behavior
|
|
78
|
-
* @returns UseFloatingTreeReturn with tree management methods and root context
|
|
79
|
-
*/
|
|
80
|
-
export declare function useFloatingTree(anchorEl: Ref<AnchorElement>, floatingEl: Ref<FloatingElement>, options?: UseFloatingOptions, treeOptions?: FloatingTreeOptions): UseFloatingTreeReturn;
|
|
81
|
-
/**
|
|
82
|
-
* Creates a reactive tree node with data, parent reference, and children references.
|
|
83
|
-
* @param data The data to store in the node
|
|
84
|
-
* @param parent The parent node, or null for root nodes
|
|
85
|
-
* @param options Configuration options for the node
|
|
86
|
-
* @param isRoot Whether this node is the true root of a tree
|
|
87
|
-
* @returns A reactive tree node object with methods and reactive properties
|
|
88
|
-
*/
|
|
89
|
-
export declare function createTreeNode<T>(data: T, parent?: TreeNode<T> | null, options?: CreateTreeNodeOptions, isRoot?: boolean): TreeNode<T>;
|
|
90
|
-
/**
|
|
91
|
-
* Creates and manages a reactive tree structure.
|
|
92
|
-
*
|
|
93
|
-
* This factory function provides a complete tree data structure with reactive nodes,
|
|
94
|
-
* supporting operations like adding, removing, and moving nodes, as well as
|
|
95
|
-
* traversal and search functionality.
|
|
96
|
-
*
|
|
97
|
-
* @template T The type of data stored in the tree nodes.
|
|
98
|
-
* @param initialRootData Data for the root node.
|
|
99
|
-
* @param options Configuration options for the tree behavior.
|
|
100
|
-
* @returns A tree management object with methods and reactive properties
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* ```ts
|
|
104
|
-
* const myTree = createTree({ name: 'Root' });
|
|
105
|
-
* const childNode = myTree.addNode({ name: 'Child' }, myTree.root.id);
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
export declare function createTree<T>(initialRootData: T, options?: CreateTreeOptions): Tree<T>;
|
|
109
|
-
export {};
|
|
110
|
-
//# sourceMappingURL=use-floating-tree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-floating-tree.d.ts","sourceRoot":"","sources":["../../src/composables/use-floating-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG9B,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EACnB,MAAM,gBAAgB,CAAA;AAOvB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAEhC;;;;OAIG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;CACxC;AAID,MAAM,WAAW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