v-float 0.1.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.
Files changed (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +210 -0
  3. package/dist/composables/index.d.ts +7 -0
  4. package/dist/composables/index.d.ts.map +1 -0
  5. package/dist/composables/interactions/index.d.ts +6 -0
  6. package/dist/composables/interactions/index.d.ts.map +1 -0
  7. package/dist/composables/interactions/use-click.d.ts +52 -0
  8. package/dist/composables/interactions/use-click.d.ts.map +1 -0
  9. package/dist/composables/interactions/use-client-point.d.ts +58 -0
  10. package/dist/composables/interactions/use-client-point.d.ts.map +1 -0
  11. package/dist/composables/interactions/use-dismiss.d.ts +68 -0
  12. package/dist/composables/interactions/use-dismiss.d.ts.map +1 -0
  13. package/dist/composables/interactions/use-focus.d.ts +30 -0
  14. package/dist/composables/interactions/use-focus.d.ts.map +1 -0
  15. package/dist/composables/interactions/use-hover.d.ts +64 -0
  16. package/dist/composables/interactions/use-hover.d.ts.map +1 -0
  17. package/dist/composables/middlewares/arrow.d.ts +26 -0
  18. package/dist/composables/middlewares/arrow.d.ts.map +1 -0
  19. package/dist/composables/middlewares/index.d.ts +3 -0
  20. package/dist/composables/middlewares/index.d.ts.map +1 -0
  21. package/dist/composables/use-arrow.d.ts +46 -0
  22. package/dist/composables/use-arrow.d.ts.map +1 -0
  23. package/dist/composables/use-floating-tree.d.ts +48 -0
  24. package/dist/composables/use-floating-tree.d.ts.map +1 -0
  25. package/dist/composables/use-floating.d.ts +161 -0
  26. package/dist/composables/use-floating.d.ts.map +1 -0
  27. package/dist/composables/use-tree.d.ts +151 -0
  28. package/dist/composables/use-tree.d.ts.map +1 -0
  29. package/dist/composables/utils/dom.d.ts +11 -0
  30. package/dist/composables/utils/dom.d.ts.map +1 -0
  31. package/dist/composables/utils/use-composition.d.ts +4 -0
  32. package/dist/composables/utils/use-composition.d.ts.map +1 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/types.d.ts +3 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/utils/dom.d.ts +9 -0
  38. package/dist/utils/dom.d.ts.map +1 -0
  39. package/dist/utils/id.d.ts +2 -0
  40. package/dist/utils/id.d.ts.map +1 -0
  41. package/dist/utils/index.d.ts +5 -0
  42. package/dist/utils/index.d.ts.map +1 -0
  43. package/dist/utils/reactivity.d.ts +2 -0
  44. package/dist/utils/reactivity.d.ts.map +1 -0
  45. package/dist/utils/type-guards.d.ts +8 -0
  46. package/dist/utils/type-guards.d.ts.map +1 -0
  47. package/dist/v-float.es.js +1956 -0
  48. package/dist/v-float.umd.js +1 -0
  49. package/package.json +63 -0
@@ -0,0 +1,48 @@
1
+ import { FloatingContext } from './use-floating';
2
+ import { TreeNode, TreeOptions } from './use-tree';
3
+ /**
4
+ * Configuration options for the floating tree
5
+ */
6
+ export interface FloatingTreeOptions extends TreeOptions {
7
+ }
8
+ export interface UseFloatingTreeReturn {
9
+ readonly nodeMap: Readonly<Map<string, TreeNode<FloatingContext>>>;
10
+ readonly root: Readonly<TreeNode<FloatingContext>>;
11
+ findNodeById: (nodeId: string) => TreeNode<FloatingContext> | null;
12
+ moveNode: (nodeId: string, newParentId: string | null) => boolean;
13
+ dispose: () => void;
14
+ addNode: (data: FloatingContext, parentId?: string | null) => TreeNode<FloatingContext> | null;
15
+ removeNode: (nodeId: string, deleteStrategy?: "orphan" | "recursive") => boolean;
16
+ traverse: (mode: "dfs" | "bfs", startNode?: TreeNode<FloatingContext>) => TreeNode<FloatingContext>[];
17
+ /**
18
+ * Checks if a given node is the topmost open node in the tree hierarchy.
19
+ * A node is considered topmost if it's open and none of its ancestors are open.
20
+ *
21
+ * @param nodeId - The ID of the node to check.
22
+ * @returns True if the node is open and no ancestors are open, false otherwise.
23
+ */
24
+ isTopmost: (nodeId: string) => boolean;
25
+ getAllOpenNodes: () => TreeNode<FloatingContext>[];
26
+ /**
27
+ * Executes a provided function once for each tree node that matches the specified relationship.
28
+ * This is a flexible iteration method that can target nodes based on their relationship to a target node.
29
+ *
30
+ * @param nodeId - The ID of the target node used as a reference point for the relationship
31
+ * @param callback - A function to execute for each matching node
32
+ * @param options - Configuration options for the iteration behavior
33
+ */
34
+ forEach: (nodeId: string, callback: (node: TreeNode<FloatingContext>) => void, options?: {
35
+ relationship?: NodeRelationship;
36
+ applyToMatching?: boolean;
37
+ }) => void;
38
+ }
39
+ /**
40
+ * Predefined node relationship strategies used for filtering nodes.
41
+ */
42
+ 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";
43
+ /**
44
+ * Manages a hierarchical tree of floating elements.
45
+ */
46
+ export declare function useFloatingTree(rootNodeData: FloatingContext, options?: FloatingTreeOptions): UseFloatingTreeReturn;
47
+ export {};
48
+ //# sourceMappingURL=use-floating-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-floating-tree.d.ts","sourceRoot":"","sources":["../../src/composables/use-floating-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAQ,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAMlE;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;CAAG;AAE3D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;IAClE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAA;IAClD,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,QAAQ,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;IAClE,QAAQ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AutoUpdateOptions, Middleware, MiddlewareData, Placement, Strategy, VirtualElement } from '@floating-ui/dom';
2
+ import { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
3
+ /**
4
+ * Type for anchor element in floating UI
5
+ */
6
+ export type AnchorElement = HTMLElement | VirtualElement | null;
7
+ /**
8
+ * Type for floating element in floating UI
9
+ */
10
+ export type FloatingElement = HTMLElement | null;
11
+ /**
12
+ * CSS styles for positioning floating elements
13
+ */
14
+ export type FloatingStyles = {
15
+ /**
16
+ * CSS position property
17
+ */
18
+ position: Strategy;
19
+ /**
20
+ * CSS top property
21
+ */
22
+ top: string;
23
+ /**
24
+ * CSS left property
25
+ */
26
+ left: string;
27
+ /**
28
+ * CSS transform property
29
+ */
30
+ transform?: string;
31
+ /**
32
+ * CSS will-change property
33
+ */
34
+ "will-change"?: string;
35
+ } & {
36
+ [key: `--${string}`]: any;
37
+ };
38
+ /**
39
+ * Options for configuring floating element behavior
40
+ */
41
+ export interface UseFloatingOptions {
42
+ /**
43
+ * Where to place the floating element relative to its anchor element.
44
+ * @default 'bottom'
45
+ */
46
+ placement?: MaybeRefOrGetter<Placement | undefined>;
47
+ /**
48
+ * The type of CSS positioning to use.
49
+ * @default 'absolute'
50
+ */
51
+ strategy?: MaybeRefOrGetter<Strategy | undefined>;
52
+ /**
53
+ * Whether to use CSS transform instead of top/left positioning.
54
+ * @default true
55
+ */
56
+ transform?: MaybeRefOrGetter<boolean | undefined>;
57
+ /**
58
+ * Middlewares modify the positioning coordinates in some fashion, or provide useful data for the consumer to use.
59
+ */
60
+ middlewares?: Middleware[];
61
+ /**
62
+ * Function called when both the anchor and floating elements are mounted.
63
+ */
64
+ whileElementsMounted?: (anchorEl: NonNullable<AnchorElement>, floatingEl: NonNullable<FloatingElement>, update: () => void) => undefined | (() => void);
65
+ /**
66
+ * Whether the floating element is open.
67
+ * @default false
68
+ */
69
+ open?: Ref<boolean>;
70
+ /**
71
+ * Function to control the open state of the floating element. If not provided, a default function is used that updates the `open` ref.
72
+ */
73
+ setOpen?: (open: boolean) => void;
74
+ }
75
+ /**
76
+ * Context object returned by useFloating containing all necessary data and methods
77
+ */
78
+ export interface FloatingContext {
79
+ /**
80
+ * The x-coordinate of the floating element
81
+ */
82
+ x: Readonly<Ref<number>>;
83
+ /**
84
+ * The y-coordinate of the floating element
85
+ */
86
+ y: Readonly<Ref<number>>;
87
+ /**
88
+ * The strategy used for positioning
89
+ */
90
+ strategy: Readonly<Ref<Strategy>>;
91
+ /**
92
+ * The placement of the floating element
93
+ */
94
+ placement: Readonly<Ref<Placement>>;
95
+ /**
96
+ * Data from middleware for additional customization
97
+ */
98
+ middlewareData: Readonly<Ref<MiddlewareData>>;
99
+ /**
100
+ * Whether the floating element has been positioned
101
+ */
102
+ isPositioned: Readonly<Ref<boolean>>;
103
+ /**
104
+ * Computed styles to apply to the floating element
105
+ */
106
+ floatingStyles: ComputedRef<FloatingStyles>;
107
+ /**
108
+ * Function to manually update the position
109
+ */
110
+ update: () => void;
111
+ /**
112
+ * The refs object containing references to anchor and floating elements
113
+ */
114
+ refs: {
115
+ anchorEl: Ref<AnchorElement>;
116
+ floatingEl: Ref<FloatingElement>;
117
+ };
118
+ /**
119
+ * Whether the floating element is open
120
+ */
121
+ open: Readonly<Ref<boolean>>;
122
+ /**
123
+ * Function to explicitly set the open state of the floating element.
124
+ */
125
+ setOpen: (open: boolean) => void;
126
+ }
127
+ /**
128
+ * Composable function that provides positioning for a floating element relative to an anchor element
129
+ *
130
+ * This composable handles the positioning logic for floating elements (like tooltips, popovers, etc.)
131
+ * relative to their anchor elements. It uses Floating UI under the hood and provides reactive
132
+ * positioning data and styles.
133
+ *
134
+ * @param anchorEl - The anchor element or a reactive reference to it
135
+ * @param floatingEl - The floating element or a reactive reference to it
136
+ * @param options - Additional options for the floating behavior
137
+ * @returns A FloatingContext object containing positioning data and methods
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const { floatingStyles, refs } = useFloating(anchorEl, floatingEl, {
142
+ * placement: 'bottom',
143
+ * strategy: 'absolute'
144
+ * })
145
+ * ```
146
+ */
147
+ export declare function useFloating(anchorEl: Ref<AnchorElement>, floatingEl: Ref<FloatingElement>, options?: UseFloatingOptions): FloatingContext;
148
+ /**
149
+ * Auto-update function to use with `whileElementsMounted` option
150
+ *
151
+ * This function provides automatic position updates for floating elements.
152
+ * It's a wrapper around Floating UI's autoUpdate function.
153
+ *
154
+ * @param anchorEl - The anchor element
155
+ * @param floatingEl - The floating element
156
+ * @param update - The update function to call
157
+ * @param options - Additional options for auto-updating
158
+ * @returns A cleanup function to stop auto-updating
159
+ */
160
+ export declare function autoUpdate(anchorEl: HTMLElement, floatingEl: HTMLElement, update: () => void, options?: AutoUpdateOptions): () => void;
161
+ //# sourceMappingURL=use-floating.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-floating.d.ts","sourceRoot":"","sources":["../../src/composables/use-floating.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,SAAS,EACT,QAAQ,EACR,cAAc,EACf,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,WAAW,EAAiB,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAO5E;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,cAAc,GAAG,IAAI,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,IAAI,CAAA;AAEhD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAA;IAElB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,GAAG;IAGF,CAAC,GAAG,EAAE,KAAK,M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AC,OAAO,CAAC,CAAC,CAAA;IAEpC;;OAEG;IACH,cAAc,EAAE,WAAW,CAAC,cAAc,CAAC,CAAA;IAE3C;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAA;IAElB;;OAEG;IACH,IAAI,EAAE;QACJ,QAAQ,EAAE,GAAG,CAAC,aAAa,CAAC,CAAA;QAC5B,UAAU,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;KACjC,CAAA;IAED;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAE5B;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;CACjC;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,GAAG,CAAC,aAAa,CAAC,EAC5B,UAAU,EAAE,GAAG,CAAC,eAAe,CAAC,EAChC,OAAO,GAAE,kBAAuB,GAC/B,eAAe,CA2HjB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,WAAW,EACrB,UAAU,EAAE,WAAW,EACvB,MAAM,EAAE,MAAM,IAAI,EAClB,OAAO,GAAE,iBAAsB,cAGhC"}
@@ -0,0 +1,151 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * Options for creating a TreeNode
4
+ */
5
+ export interface TreeNodeOptions {
6
+ /** Optional ID for the node. If not provided, one will be generated. */
7
+ id?: string;
8
+ }
9
+ /**
10
+ * Options for configuring tree behavior
11
+ */
12
+ export interface TreeOptions {
13
+ /** Strategy for deleting child nodes when a parent is deleted.
14
+ * - 'orphan': Children are detached from the tree (parent becomes null).
15
+ * - 'recursive': Children are also deleted recursively.
16
+ * @default 'recursive'
17
+ */
18
+ deleteStrategy?: "orphan" | "recursive";
19
+ }
20
+ /**
21
+ * Represents a node in a reactive tree structure.
22
+ * Each node contains data, parent reference, and children references.
23
+ */
24
+ export declare class TreeNode<T> {
25
+ #private;
26
+ readonly id: string;
27
+ data: T;
28
+ parent: Ref<TreeNode<T> | null>;
29
+ children: Ref<TreeNode<T>[]>;
30
+ constructor(data: T, parent?: TreeNode<T> | null, options?: TreeNodeOptions, isRoot?: boolean);
31
+ /**
32
+ * Adds an existing node instance to this node's children array.
33
+ * @internal
34
+ * @param childNode The TreeNode instance to add.
35
+ */
36
+ addChild(childNode: TreeNode<T>): void;
37
+ /**
38
+ * Removes a specific child node instance from this node's children.
39
+ * @internal
40
+ * Note: This only removes the direct child link. Use the Tree's `removeNode` method for full removal including map updates and recursive deletion.
41
+ * @param childNode The child node instance to remove.
42
+ * @returns True if the child was found and removed, false otherwise.
43
+ */
44
+ _removeChildInstance(childNode: TreeNode<T>): boolean;
45
+ /**
46
+ * Updates the node's data.
47
+ * If T is an object, performs a shallow merge using Object.assign.
48
+ * If T is a primitive, replaces the value.
49
+ * @param newData Partial data for objects, or the new value for primitives.
50
+ */
51
+ updateData(newData: Partial<T> | T): void;
52
+ /**
53
+ * Finds the first direct child matching the predicate.
54
+ * @param predicate Function to test each child node.
55
+ * @returns The matching child node or null if not found.
56
+ */
57
+ findChild(predicate: (node: TreeNode<T>) => boolean): TreeNode<T> | null;
58
+ /**
59
+ * Finds the first descendant node (including self) matching the predicate using DFS.
60
+ * @param predicate Function to test each node.
61
+ * @returns The matching descendant node or null if not found.
62
+ */
63
+ findDescendant(predicate: (node: TreeNode<T>) => boolean): TreeNode<T> | null;
64
+ /**
65
+ * Checks if this node is a descendant of the potential ancestor.
66
+ * @param potentialAncestor The node to check against.
67
+ * @returns True if this node is a descendant, false otherwise.
68
+ */
69
+ isDescendantOf(potentialAncestor: TreeNode<T>): boolean;
70
+ /**
71
+ * Gets the path of nodes from the root to this node.
72
+ * @returns An array of nodes starting with the root and ending with this node.
73
+ */
74
+ getPath(): TreeNode<T>[];
75
+ /** Checks if the node is the true root of the tree, distinct from an orphaned node. */
76
+ get isRoot(): boolean;
77
+ /** Checks if the node is a leaf node (has no children). */
78
+ get isLeaf(): boolean;
79
+ }
80
+ /**
81
+ * Manages a reactive tree structure.
82
+ *
83
+ * This class provides a complete tree data structure with reactive nodes,
84
+ * supporting operations like adding, removing, and moving nodes, as well as
85
+ * traversal and search functionality.
86
+ *
87
+ * @template T The type of data stored in the tree nodes.
88
+ */
89
+ export declare class Tree<T> {
90
+ #private;
91
+ /** The root node of the tree. */
92
+ readonly root: TreeNode<T>;
93
+ /** Readonly reactive map of node IDs to TreeNode instances for quick lookups. */
94
+ readonly nodeMap: Readonly<Map<string, TreeNode<T>>>;
95
+ /**
96
+ * Creates a new Tree instance.
97
+ * @param initialRootData Data for the root node.
98
+ * @param options Configuration options for the tree behavior.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const myTree = new Tree({ name: 'Root' });
103
+ * const childNode = myTree.addNode({ name: 'Child' }, myTree.root.id);
104
+ * ```
105
+ */
106
+ constructor(initialRootData: T, options?: TreeOptions);
107
+ /**
108
+ * Finds a node anywhere in the tree by its ID.
109
+ * @param id The ID of the node to find.
110
+ * @returns The node if found, otherwise null.
111
+ */
112
+ findNodeById(id: string): TreeNode<T> | null;
113
+ /**
114
+ * Adds a new node to the tree.
115
+ * @param data The data for the new node.
116
+ * @param parentId The ID of the parent node. If null or undefined, adds to the root.
117
+ * @param nodeOptions Optional configuration for the new node (e.g., custom ID).
118
+ * @returns The newly created TreeNode, or null if the parent was not found.
119
+ */
120
+ addNode(data: T, parentId?: string | null, nodeOptions?: TreeNodeOptions): TreeNode<T> | null;
121
+ /**
122
+ * Removes a node from the tree by its ID.
123
+ * Handles deletion of descendants based on the provided strategy or the tree's default.
124
+ * @param nodeId The ID of the node to remove.
125
+ * @param deleteStrategy Optional strategy override. If not provided, uses the tree's default strategy.
126
+ * @returns True if the node was successfully removed, false otherwise.
127
+ */
128
+ removeNode(nodeId: string, deleteStrategy?: "orphan" | "recursive"): boolean;
129
+ /**
130
+ * Moves a node to become a child of a new parent.
131
+ * @param nodeId The ID of the node to move.
132
+ * @param newParentId The ID of the new parent node. Set to null to move to the root level.
133
+ * @returns True if the node was successfully moved, false otherwise.
134
+ */
135
+ moveNode(nodeId: string, newParentId: string | null): boolean;
136
+ /**
137
+ * Traverses the tree using either Depth-First Search (DFS) or Breadth-First Search (BFS).
138
+ * @param strategy The traversal strategy ('dfs' or 'bfs'). Defaults to 'dfs'.
139
+ * @param startNode The node to start traversal from. Defaults to the root node.
140
+ * @returns An array of nodes in the order they were visited.
141
+ */
142
+ traverse(strategy?: "dfs" | "bfs", startNode?: TreeNode<T> | null): TreeNode<T>[];
143
+ /**
144
+ * Clears the internal node map. This is crucial for allowing garbage collection
145
+ * when the Tree instance is no longer needed, especially in scenarios like
146
+ * Vue components where the instance might be tied to the component lifecycle.
147
+ * Call this method when you are finished with the Tree instance (e.g., in `onScopeDispose`).
148
+ */
149
+ dispose(): void;
150
+ }
151
+ //# sourceMappingURL=use-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["../../src/composables/use-tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAA+B,MAAM,KAAK,CAAA;AAO3D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAE1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAA;CACxC;AAQD;;;GAGG;AACH,qBAAa,QAAQ,CAAC,CAAC;;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,CAAC,CAAA;IACP,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IAC/B,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;gBAI1B,IAAI,EAAE,CAAC,EACP,MAA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QrD;;;;OAIG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAI5C;;;;;;OAMG;IACH,OAAO,CACL,IAAI,EAAE,CAAC,EACP,QAAQ,GAAE,MAAM,GAAG,IAAW,EAC9B,WAAW,GAAE,eAAoB,GAChC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAqBrB;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO;IAiC5E;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IAqD7D;;;;;OAKG;IACH,QAAQ,CACN,QAAQ,GAAE,KAAK,GAAG,KAAa,EAC/B,SAAS,GAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAgB,GACxC,QAAQ,CAAC,CAAC,CAAC,EAAE;IAgChB;;;;;OAKG;IACH,OAAO,IAAI,IAAI;CAiBhB"}
@@ -0,0 +1,11 @@
1
+ export declare function normalizeProp(normalizable?: boolean | {
2
+ escapeKey?: boolean;
3
+ outsidePress?: boolean;
4
+ }): {
5
+ escapeKey: boolean;
6
+ outsidePress: boolean;
7
+ };
8
+ export declare function isHTMLElement(node: unknown | null): node is HTMLElement;
9
+ export declare function isEventTargetWithin(event: Event, element: Element | null | undefined): boolean;
10
+ export declare function isClickOnScrollbar(event: MouseEvent, target: HTMLElement): boolean;
11
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/composables/utils/dom.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAC3B,YAAY,CAAC,EAAE,OAAO,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE;;;EAQzE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,IAAI,WAAW,CAEvE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAU9F;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAalF"}
@@ -0,0 +1,4 @@
1
+ export declare function useComposition(): {
2
+ isComposing: () => boolean;
3
+ };
4
+ //# sourceMappingURL=use-composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-composition.d.ts","sourceRoot":"","sources":["../../../src/composables/utils/use-composition.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc;;EAc7B"}
@@ -0,0 +1,2 @@
1
+ export * from './composables';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -0,0 +1,3 @@
1
+ export type AnyFn<T extends unknown[] = unknown[], U = unknown> = (...args: T) => U;
2
+ export type Fn = () => void;
3
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAA;AACnF,MAAM,MAAM,EAAE,GAAG,MAAM,IAAI,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Rounds a value based on the device pixel ratio
3
+ */
4
+ export declare function roundByDPR(el: HTMLElement, value: number): number;
5
+ /**
6
+ * Gets the device pixel ratio for an element
7
+ */
8
+ export declare function getDPR(el: HTMLElement): number;
9
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,UAGxD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,WAAW,UAIrC"}
@@ -0,0 +1,2 @@
1
+ export declare function useId(): string;
2
+ //# sourceMappingURL=id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/utils/id.ts"],"names":[],"mappings":"AAEA,wBAAgB,KAAK,IAAI,MAAM,CAE9B"}
@@ -0,0 +1,5 @@
1
+ export * from './dom';
2
+ export * from './reactivity';
3
+ export * from './type-guards';
4
+ export * from './id';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function isWatchable(source: unknown): boolean;
2
+ //# sourceMappingURL=reactivity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactivity.d.ts","sourceRoot":"","sources":["../../src/utils/reactivity.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEpD"}
@@ -0,0 +1,8 @@
1
+ import { AnyFn } from '../types';
2
+ /**
3
+ * Checks if a value is a function
4
+ * @param value - The value to check
5
+ * @returns True if the value is a function, false otherwise
6
+ */
7
+ export declare function isFunction(value: unknown): value is AnyFn;
8
+ //# sourceMappingURL=type-guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../../src/utils/type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAEzD"}