v-float 0.4.0 → 0.6.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/dist/composables/index.d.ts +2 -3
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/interactions/index.d.ts +3 -3
- package/dist/composables/interactions/index.d.ts.map +1 -1
- package/dist/composables/interactions/polygon.d.ts +1 -1
- 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-client-point.d.ts +180 -20
- package/dist/composables/interactions/use-client-point.d.ts.map +1 -1
- package/dist/composables/interactions/use-escape-key.d.ts +37 -4
- package/dist/composables/interactions/use-escape-key.d.ts.map +1 -1
- package/dist/composables/interactions/use-focus.d.ts +2 -2
- package/dist/composables/interactions/use-focus.d.ts.map +1 -1
- package/dist/composables/interactions/use-hover.d.ts +1 -1
- package/dist/composables/interactions/use-hover.d.ts.map +1 -1
- package/dist/composables/interactions/utils/index.d.ts +3 -3
- package/dist/composables/interactions/utils/index.d.ts.map +1 -1
- package/dist/composables/interactions/utils/tree-context.d.ts +2 -2
- package/dist/composables/interactions/utils/tree-context.d.ts.map +1 -1
- package/dist/composables/middlewares/index.d.ts +1 -1
- package/dist/composables/middlewares/index.d.ts.map +1 -1
- package/dist/composables/use-arrow.d.ts +0 -5
- package/dist/composables/use-arrow.d.ts.map +1 -1
- package/dist/composables/use-floating-tree.d.ts +72 -10
- package/dist/composables/use-floating-tree.d.ts.map +1 -1
- package/dist/composables/use-floating.d.ts +1 -1
- package/dist/composables/use-floating.d.ts.map +1 -1
- package/dist/v-float.es.js +2313 -2166
- package/dist/v-float.umd.js +1 -1
- package/package.json +2 -2
- package/dist/composables/use-tree.d.ts +0 -144
- package/dist/composables/use-tree.d.ts.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 V-Float
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 V-Float
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from './use-floating';
|
|
2
|
-
export * from './use-arrow';
|
|
3
1
|
export * from './interactions';
|
|
4
2
|
export * from './middlewares';
|
|
5
|
-
export * from './use-
|
|
3
|
+
export * from './use-arrow';
|
|
4
|
+
export * from './use-floating';
|
|
6
5
|
export * from './use-floating-tree';
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/composables/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './use-hover';
|
|
2
|
-
export * from './use-focus';
|
|
3
1
|
export * from './use-click';
|
|
4
|
-
export
|
|
2
|
+
export { type AxisConstraint, type Coordinates, type TrackingMode, type UseClientPointContext, type UseClientPointOptions, type UseClientPointReturn, useClientPoint, } from './use-client-point';
|
|
5
3
|
export * from './use-escape-key';
|
|
4
|
+
export * from './use-focus';
|
|
5
|
+
export * from './use-hover';
|
|
6
6
|
export * from './utils';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,cAAc,GACf,MAAM,oBAAoB,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/polygon.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/polygon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAGtF,KAAK,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC7B,KAAK,OAAO,GAAG,KAAK,EAAE,CAAA;AAoDtB,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAC7C;AAED,MAAM,WAAW,+BAA+B;IAC9C,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAA;IAChD,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa,GAAG,IAAI,CAAA;QAClC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAA;KACjC,CAAA;IACD,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAA;KAAE,CAAA;CACzD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;cAsCJ,+BAA+B,WAehD,UAAU;;;;EAiVhD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FloatingContext } from '..';
|
|
2
|
-
import { TreeNode } from '../use-tree';
|
|
3
1
|
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { FloatingContext } from '..';
|
|
3
|
+
import { TreeNode } from '../use-floating-tree';
|
|
4
4
|
/**
|
|
5
5
|
* Enables showing/hiding the floating element when clicking the reference element
|
|
6
6
|
* and optionally when clicking outside both the reference and floating elements.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-click.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-click.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-click.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-click.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,gBAAgB,EA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;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;CAC7C"}
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VirtualElement } from '@floating-ui/dom';
|
|
2
2
|
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
3
|
+
import { AnchorElement } from '../use-floating';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
|
|
5
|
+
* Represents 2D coordinates with optional null values for unset states
|
|
6
|
+
*/
|
|
7
|
+
export interface Coordinates {
|
|
8
|
+
x: number | null;
|
|
9
|
+
y: number | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Axis constraint types for coordinate positioning
|
|
13
|
+
*/
|
|
14
|
+
export type AxisConstraint = "x" | "y" | "both";
|
|
15
|
+
/**
|
|
16
|
+
* Tracking mode for client point positioning behavior
|
|
17
|
+
*/
|
|
18
|
+
export type TrackingMode = "follow" | "static";
|
|
19
|
+
/**
|
|
20
|
+
* Processed pointer event data
|
|
21
|
+
*/
|
|
22
|
+
interface PointerEventData {
|
|
23
|
+
type: "pointerdown" | "pointermove" | "pointerenter";
|
|
24
|
+
coordinates: Coordinates;
|
|
25
|
+
originalEvent: PointerEvent;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Context for tracking strategy operations
|
|
21
29
|
*/
|
|
22
|
-
|
|
30
|
+
interface TrackingContext {
|
|
31
|
+
isOpen: boolean;
|
|
32
|
+
}
|
|
23
33
|
export interface UseClientPointOptions {
|
|
24
34
|
/**
|
|
25
35
|
* Whether the Hook is enabled
|
|
@@ -30,7 +40,7 @@ export interface UseClientPointOptions {
|
|
|
30
40
|
* Whether to restrict the client point to an axis
|
|
31
41
|
* @default 'both'
|
|
32
42
|
*/
|
|
33
|
-
axis?: MaybeRefOrGetter<
|
|
43
|
+
axis?: MaybeRefOrGetter<AxisConstraint>;
|
|
34
44
|
/**
|
|
35
45
|
* Controlled x coordinate
|
|
36
46
|
* @default null
|
|
@@ -41,6 +51,13 @@ export interface UseClientPointOptions {
|
|
|
41
51
|
* @default null
|
|
42
52
|
*/
|
|
43
53
|
y?: MaybeRefOrGetter<number | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Tracking behavior mode:
|
|
56
|
+
* - "follow": Continuous cursor tracking (default)
|
|
57
|
+
* - "static": Position at initial interaction, no subsequent tracking
|
|
58
|
+
* @default "follow"
|
|
59
|
+
*/
|
|
60
|
+
trackingMode?: TrackingMode;
|
|
44
61
|
}
|
|
45
62
|
export interface UseClientPointReturn {
|
|
46
63
|
/**
|
|
@@ -55,4 +72,147 @@ export interface UseClientPointReturn {
|
|
|
55
72
|
*/
|
|
56
73
|
updatePosition: (x: number, y: number) => void;
|
|
57
74
|
}
|
|
75
|
+
export interface UseClientPointContext {
|
|
76
|
+
open: Readonly<Ref<boolean>>;
|
|
77
|
+
refs: {
|
|
78
|
+
anchorEl: Ref<AnchorElement>;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Virtual element factory for floating positioning anchors.
|
|
83
|
+
* Creates virtual DOM elements that serve as positioning anchors.
|
|
84
|
+
*/
|
|
85
|
+
export declare class VirtualElementFactory {
|
|
86
|
+
private static readonly DEFAULT_DIMENSIONS;
|
|
87
|
+
/**
|
|
88
|
+
* Create a virtual anchor element
|
|
89
|
+
*/
|
|
90
|
+
create(options: {
|
|
91
|
+
coordinates: Coordinates;
|
|
92
|
+
referenceElement?: HTMLElement | null;
|
|
93
|
+
baselineCoordinates?: Coordinates | null;
|
|
94
|
+
axis?: AxisConstraint;
|
|
95
|
+
}): VirtualElement;
|
|
96
|
+
/**
|
|
97
|
+
* Build configuration from options with defaults
|
|
98
|
+
*/
|
|
99
|
+
private buildConfiguration;
|
|
100
|
+
/**
|
|
101
|
+
* Build the bounding rectangle for the virtual element
|
|
102
|
+
*/
|
|
103
|
+
private buildBoundingRect;
|
|
104
|
+
/**
|
|
105
|
+
* Get reference element bounds with fallback
|
|
106
|
+
*/
|
|
107
|
+
private getReferenceRect;
|
|
108
|
+
/**
|
|
109
|
+
* Resolve final position from coordinate sources
|
|
110
|
+
*/
|
|
111
|
+
private resolvePosition;
|
|
112
|
+
/**
|
|
113
|
+
* Resolve coordinate for a single axis with clear precedence
|
|
114
|
+
*/
|
|
115
|
+
private resolveAxisCoordinate;
|
|
116
|
+
/**
|
|
117
|
+
* Calculate virtual element size based on axis constraints
|
|
118
|
+
*/
|
|
119
|
+
private calculateSize;
|
|
120
|
+
/**
|
|
121
|
+
* Build a DOMRect object
|
|
122
|
+
*/
|
|
123
|
+
private buildDOMRect;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Abstract base class for tracking strategies
|
|
127
|
+
*/
|
|
128
|
+
export declare abstract class TrackingStrategy {
|
|
129
|
+
abstract readonly name: TrackingMode;
|
|
130
|
+
protected lastKnownCoordinates: Coordinates | null;
|
|
131
|
+
/**
|
|
132
|
+
* Process a pointer event and return coordinates if the strategy wants to update
|
|
133
|
+
* This is the heart of each strategy's behavior
|
|
134
|
+
*/
|
|
135
|
+
abstract process(event: PointerEventData, context: TrackingContext): Coordinates | null;
|
|
136
|
+
/**
|
|
137
|
+
* Get the list of pointer events this strategy needs to listen for
|
|
138
|
+
* This allows strategies to optimize performance by only registering necessary events
|
|
139
|
+
*/
|
|
140
|
+
abstract getRequiredEvents(): PointerEventData["type"][];
|
|
141
|
+
/**
|
|
142
|
+
* Get coordinates to use when the floating element opens
|
|
143
|
+
* This lets each strategy decide its opening behavior without client code needing to know the details
|
|
144
|
+
*/
|
|
145
|
+
getCoordinatesForOpening(): Coordinates | null;
|
|
146
|
+
/**
|
|
147
|
+
* Called when the floating element closes
|
|
148
|
+
* This is where strategies should clean up any temporary state
|
|
149
|
+
*/
|
|
150
|
+
onClose(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Reset all strategy state - used when the composable is disabled or reset
|
|
153
|
+
*/
|
|
154
|
+
reset(): void;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Strategy for continuous cursor tracking
|
|
158
|
+
*/
|
|
159
|
+
export declare class FollowTracker extends TrackingStrategy {
|
|
160
|
+
readonly name: "follow";
|
|
161
|
+
/**
|
|
162
|
+
* Follow strategy needs all pointer events for continuous tracking
|
|
163
|
+
*/
|
|
164
|
+
getRequiredEvents(): PointerEventData["type"][];
|
|
165
|
+
/**
|
|
166
|
+
* Follow strategy: always update coordinates based on the current pointer position
|
|
167
|
+
* This creates smooth, continuous tracking behavior
|
|
168
|
+
*/
|
|
169
|
+
process(event: PointerEventData, context: TrackingContext): Coordinates | null;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Strategy for static positioning at initial interaction
|
|
173
|
+
*/
|
|
174
|
+
export declare class StaticTracker extends TrackingStrategy {
|
|
175
|
+
readonly name: "static";
|
|
176
|
+
private triggerCoordinates;
|
|
177
|
+
/**
|
|
178
|
+
* Static strategy only needs click events, not hover or continuous movement
|
|
179
|
+
* This optimization avoids registering unnecessary pointer events
|
|
180
|
+
*/
|
|
181
|
+
getRequiredEvents(): PointerEventData["type"][];
|
|
182
|
+
/**
|
|
183
|
+
* Static strategy: capture coordinates from trigger events, ignore movement
|
|
184
|
+
* This creates stable positioning that doesn't jump around
|
|
185
|
+
*/
|
|
186
|
+
process(event: PointerEventData, context: TrackingContext): Coordinates | null;
|
|
187
|
+
/**
|
|
188
|
+
* Get coordinates to use when floating element opens
|
|
189
|
+
*/
|
|
190
|
+
getCoordinatesForOpening(): Coordinates | null;
|
|
191
|
+
/**
|
|
192
|
+
* Reset tracking state
|
|
193
|
+
*/
|
|
194
|
+
reset(): void;
|
|
195
|
+
onClose(): void;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Positions the floating element relative to a client point (mouse position).
|
|
199
|
+
*
|
|
200
|
+
* This composable tracks pointer movements and positions the floating element
|
|
201
|
+
* accordingly, with options for axis locking and controlled coordinates.
|
|
202
|
+
*
|
|
203
|
+
* @param pointerTarget - The DOM element whose bounding box is used as the reference for pointer event listeners and initial positioning.
|
|
204
|
+
* @param context - The floating context with open state and position reference
|
|
205
|
+
* @param options - Configuration options for client point behavior
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const context = useFloating(...)
|
|
210
|
+
* useClientPoint(context, {
|
|
211
|
+
* axis: "x",
|
|
212
|
+
* enabled: true
|
|
213
|
+
* })
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export declare function useClientPoint(pointerTarget: Ref<HTMLElement | null>, context: UseClientPointContext, options?: UseClientPointOptions): UseClientPointReturn;
|
|
217
|
+
export {};
|
|
58
218
|
//# sourceMappingURL=use-client-point.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-client-point.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-client-point.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"use-client-point.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-client-point.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,GAAG,EAMT,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAOpD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjB;AAED;;GAEG;AACH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;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI;CA4B/E;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAS;IAIjC,OAAO,CAAC,kBAAkB,CAA2B;IAErD;;;OAGG;IACH,iBAAiB,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;IAI/C;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI;IAW9E;;OAEG;IACH,wBAAwB,IAAI,WAAW,GAAG,IAAI;IAS9C;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb,OAAO,IAAI,IAAI;CAKhB;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,aAAa,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EACtC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,GAAE,qBAA0B,GAClC,oBAAoB,CAmLtB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { FloatingContext } from '..';
|
|
3
|
+
import { TreeNode } from '../use-floating-tree';
|
|
2
4
|
export interface UseEscapeKeyOptions {
|
|
3
5
|
/**
|
|
4
6
|
* Condition to enable the escape key listener.
|
|
@@ -11,14 +13,45 @@ export interface UseEscapeKeyOptions {
|
|
|
11
13
|
*/
|
|
12
14
|
capture?: boolean;
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
16
|
+
* Custom callback function to be executed when the escape key is pressed.
|
|
17
|
+
* When provided, overrides default behavior.
|
|
15
18
|
*/
|
|
16
|
-
onEscape
|
|
19
|
+
onEscape?: (event: KeyboardEvent) => void;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
|
-
* A composable to handle the escape key press
|
|
22
|
+
* A composable to handle the escape key press with tree-aware behavior and composition event handling.
|
|
20
23
|
*
|
|
24
|
+
* When passed a FloatingContext, it will close that floating element by setting open to false.
|
|
25
|
+
* When passed a TreeNode<FloatingContext>, it will find and close the topmost open node in the tree.
|
|
26
|
+
*
|
|
27
|
+
* @param context - The floating context or tree node with open state and change handler.
|
|
21
28
|
* @param options - {@link UseEscapeKeyOptions}
|
|
29
|
+
*
|
|
30
|
+
* @example Basic standalone usage
|
|
31
|
+
* ```ts
|
|
32
|
+
* const context = useFloating(...)
|
|
33
|
+
* useEscapeKey(context) // Closes the floating element on escape
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Tree-aware usage
|
|
37
|
+
* ```ts
|
|
38
|
+
* const tree = useFloatingTree(...)
|
|
39
|
+
* const childNode = tree.addNode(...)
|
|
40
|
+
* useEscapeKey(childNode) // Closes the topmost open node in the tree
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Custom handler
|
|
44
|
+
* ```ts
|
|
45
|
+
* useEscapeKey(context, {
|
|
46
|
+
* onEscape: (event) => {
|
|
47
|
+
* if (hasUnsavedChanges.value) {
|
|
48
|
+
* showConfirmDialog.value = true
|
|
49
|
+
* } else {
|
|
50
|
+
* context.setOpen(false)
|
|
51
|
+
* }
|
|
52
|
+
* }
|
|
53
|
+
* })
|
|
54
|
+
* ```
|
|
22
55
|
*/
|
|
23
|
-
export declare function useEscapeKey(
|
|
56
|
+
export declare function useEscapeKey(context: FloatingContext | TreeNode<FloatingContext>, options?: UseEscapeKeyOptions): void;
|
|
24
57
|
//# sourceMappingURL=use-escape-key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-escape-key.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-escape-key.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"use-escape-key.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-escape-key.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,KAAK,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAO/D,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEnC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;CAC1C;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,EACpD,OAAO,GAAE,mBAAwB,GAChC,IAAI,CAiCN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FloatingContext } from '..';
|
|
2
|
-
import { TreeNode } from '../use-tree';
|
|
3
1
|
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { FloatingContext } from '..';
|
|
3
|
+
import { TreeNode } from '../use-floating-tree';
|
|
4
4
|
/**
|
|
5
5
|
* Enables showing/hiding the floating element when focusing the reference element.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-focus.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-focus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-focus.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-focus.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EAMtB,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAc/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,EACpD,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAwIhB;AAMD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEnC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;CAChD;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-hover.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-hover.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-hover.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-hover.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,QAAQ,EAKd,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,WAAW,CAAA;AAWhE,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAE3B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAE5D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAEzB;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAE7B;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,kBAAkB,CAAC,CAAA;CACrD;AAiED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,EACpD,OAAO,GAAE,eAAoB,GAC5B,IAAI,CA8ON"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This module exports shared helper functions to eliminate code duplication
|
|
5
5
|
* across use-click, use-focus, use-hover, use-client-point, and polygon composables.
|
|
6
6
|
*/
|
|
7
|
-
export { isTreeNode, getContextFromParameter, isTargetWithinElement, findDescendantContainingTarget, } from './tree-context';
|
|
8
|
-
export { isMouseLikePointerType, isTypeableElement, isButtonTarget, isSpaceIgnored, isHTMLElement, isVirtualElement, isEventTargetWithin, isClickOnScrollbar, } from './element-detection';
|
|
9
7
|
export { isMac, isSafari, matchesFocusVisible, } from './browser-detection';
|
|
10
|
-
export {
|
|
8
|
+
export { isButtonTarget, isClickOnScrollbar, isEventTargetWithin, isHTMLElement, isMouseLikePointerType, isSpaceIgnored, isTypeableElement, isVirtualElement, } from './element-detection';
|
|
9
|
+
export { clearTimeoutIfSet, contains, getCurrentTime, getTarget, } from './event-utils';
|
|
10
|
+
export { findDescendantContainingTarget, getContextFromParameter, isTargetWithinElement, isTreeNode, } from './tree-context';
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/composables/interactions/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/composables/interactions/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,KAAK,EACL,QAAQ,EACR,mBAAmB,GACpB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,8BAA8B,EAC9B,uBAAuB,EACvB,qBAAqB,EACrB,UAAU,GACX,MAAM,gBAAgB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FloatingContext } from '../..';
|
|
2
|
-
import { TreeNode } from '../../use-tree';
|
|
2
|
+
import { TreeNode } from '../../use-floating-tree';
|
|
3
3
|
/**
|
|
4
4
|
* Type guard to determine if the context parameter is a TreeNode.
|
|
5
5
|
* @param context - The context parameter to check
|
|
@@ -21,7 +21,7 @@ export declare function getContextFromParameter(context: FloatingContext | TreeN
|
|
|
21
21
|
* @param element - The element to check containment against (can be VirtualElement or null)
|
|
22
22
|
* @returns True if the target is within the element
|
|
23
23
|
*/
|
|
24
|
-
export declare function isTargetWithinElement(target: Node, element:
|
|
24
|
+
export declare function isTargetWithinElement(target: Node, element: unknown): boolean;
|
|
25
25
|
/**
|
|
26
26
|
* Finds a descendant node that contains the target element.
|
|
27
27
|
* @param node - The parent node to search from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-context.d.ts","sourceRoot":"","sources":["../../../../src/composables/interactions/utils/tree-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tree-context.d.ts","sourceRoot":"","sources":["../../../../src/composables/interactions/utils/tree-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAE/D;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,GACnD,OAAO,IAAI,QAAQ,CAAC,eAAe,CAAC,CAStC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,GAAG;IAC7F,eAAe,EAAE,eAAe,CAAA;IAChC,WAAW,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;CAC9C,CAWA;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAkB7E;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,EAC/B,MAAM,EAAE,IAAI,GACX,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAgBlC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { flip, hide, offset, shift } from '@floating-ui/dom';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/middlewares/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/middlewares/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Padding } from '@floating-ui/dom';
|
|
2
1
|
import { ComputedRef, Ref } from 'vue';
|
|
3
2
|
import { FloatingContext } from './use-floating';
|
|
4
3
|
/**
|
|
@@ -34,10 +33,6 @@ export interface UseArrowOptions {
|
|
|
34
33
|
* @default '-4px'
|
|
35
34
|
*/
|
|
36
35
|
offset?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Padding around arrow element
|
|
39
|
-
*/
|
|
40
|
-
padding?: Padding;
|
|
41
36
|
}
|
|
42
37
|
/**
|
|
43
38
|
* Composable for computing arrow position styles for floating elements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-arrow.d.ts","sourceRoot":"","sources":["../../src/composables/use-arrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"use-arrow.d.ts","sourceRoot":"","sources":["../../src/composables/use-arrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAE3B;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAE3B;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAChC,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAyDhB"}
|
|
@@ -1,20 +1,54 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { AnchorElement, FloatingContext, FloatingElement, UseFloatingOptions } from './use-floating';
|
|
3
|
-
import { TreeNode, TreeOptions } from './use-tree';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* Options for creating a TreeNode
|
|
6
5
|
*/
|
|
7
|
-
export interface
|
|
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";
|
|
8
20
|
}
|
|
9
|
-
export interface
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
12
|
-
|
|
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;
|
|
13
41
|
moveNode: (nodeId: string, newParentId: string | null) => boolean;
|
|
42
|
+
traverse: (strategy?: "dfs" | "bfs", startNode?: TreeNode<T> | null) => TreeNode<T>[];
|
|
14
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"> {
|
|
15
51
|
addNode: (anchorEl: Ref<AnchorElement>, floatingEl: Ref<FloatingElement>, options?: UseFloatingOptions) => TreeNode<FloatingContext> | null;
|
|
16
|
-
removeNode: (nodeId: string, deleteStrategy?: "orphan" | "recursive") => boolean;
|
|
17
|
-
traverse: (mode: "dfs" | "bfs", startNode?: TreeNode<FloatingContext>) => TreeNode<FloatingContext>[];
|
|
18
52
|
getAllOpenNodes: () => TreeNode<FloatingContext>[];
|
|
19
53
|
getTopmostOpenNode: () => TreeNode<FloatingContext> | null;
|
|
20
54
|
/**
|
|
@@ -25,7 +59,7 @@ export interface UseFloatingTreeReturn {
|
|
|
25
59
|
* @param callback - A function to execute for each matching node
|
|
26
60
|
* @param options - Configuration options for the iteration behavior
|
|
27
61
|
*/
|
|
28
|
-
|
|
62
|
+
applyToNodes: (nodeId: string, callback: (node: TreeNode<FloatingContext>) => void, options?: {
|
|
29
63
|
relationship?: NodeRelationship;
|
|
30
64
|
applyToMatching?: boolean;
|
|
31
65
|
}) => void;
|
|
@@ -44,5 +78,33 @@ type NodeRelationship = "ancestors-only" | "siblings-only" | "descendants-only"
|
|
|
44
78
|
* @returns UseFloatingTreeReturn with tree management methods and root context
|
|
45
79
|
*/
|
|
46
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>;
|
|
47
109
|
export {};
|
|
48
110
|
//# sourceMappingURL=use-floating-tree.d.ts.map
|