@zag-js/tooltip 0.1.10 → 0.1.13

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Chakra UI
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
+ SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,93 @@
1
- export { connect } from "./tooltip.connect";
2
- export { machine } from "./tooltip.machine";
3
- export type { UserDefinedContext as Context } from "./tooltip.types";
1
+ import { RequiredBy, CommonProperties, RootProperties, PropTypes, NormalizeProps } from '@zag-js/types';
2
+ import * as _zag_js_core from '@zag-js/core';
3
+ import { StateMachine } from '@zag-js/core';
4
+ import { PositioningOptions } from '@zag-js/popper';
5
+
6
+ declare type ElementIds = Partial<{
7
+ trigger: string;
8
+ content: string;
9
+ }>;
10
+ declare type PublicContext = CommonProperties & {
11
+ /**
12
+ * The ids of the elements in the tooltip. Useful for composition.
13
+ */
14
+ ids?: ElementIds;
15
+ /**
16
+ * The `id` of the tooltip.
17
+ */
18
+ id: string;
19
+ /**
20
+ * The open delay of the tooltip.
21
+ */
22
+ openDelay: number;
23
+ /**
24
+ * The close delay of the tooltip.
25
+ */
26
+ closeDelay: number;
27
+ /**
28
+ * Whether to close the tooltip on pointerdown.
29
+ */
30
+ closeOnPointerDown: boolean;
31
+ /**
32
+ * Whether to close the tooltip when the Escape key is pressed.
33
+ */
34
+ closeOnEsc?: boolean;
35
+ /**
36
+ * Whether the tooltip's content is interactive.
37
+ * In this mode, the tooltip will remain open when user hovers over the content.
38
+ * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
39
+ */
40
+ interactive: boolean;
41
+ /**
42
+ * Function called when the tooltip is opened.
43
+ */
44
+ onOpen?: VoidFunction;
45
+ /**
46
+ * Function called when the tooltip is closed.
47
+ */
48
+ onClose?: VoidFunction;
49
+ /**
50
+ * Custom label for the tooltip.
51
+ */
52
+ "aria-label"?: string;
53
+ /**
54
+ * The user provided options used to position the popover content
55
+ */
56
+ positioning: PositioningOptions;
57
+ };
58
+ declare type UserDefinedContext = RequiredBy<PublicContext, "id">;
59
+ declare type ComputedContext = Readonly<{
60
+ /**
61
+ * @computed Whether an `aria-label` is set.
62
+ */
63
+ readonly hasAriaLabel: boolean;
64
+ }>;
65
+ declare type PrivateContext = RootProperties & {};
66
+ declare type MachineContext = PublicContext & ComputedContext & PrivateContext;
67
+ declare type MachineState = {
68
+ value: "unknown" | "opening" | "open" | "closing" | "closed";
69
+ tags: "open" | "closed";
70
+ };
71
+ declare type State = StateMachine.State<MachineContext, MachineState>;
72
+ declare type Send = StateMachine.Send<StateMachine.AnyEventObject>;
73
+
74
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
75
+ isOpen: boolean;
76
+ open(): void;
77
+ close(): void;
78
+ getAnimationState(): {
79
+ enter: boolean;
80
+ exit: boolean;
81
+ };
82
+ triggerProps: T["button"];
83
+ arrowProps: T["element"];
84
+ innerArrowProps: T["element"];
85
+ positionerProps: T["element"];
86
+ contentProps: T["element"];
87
+ labelProps: T["element"];
88
+ createPortal(): HTMLElement;
89
+ };
90
+
91
+ declare function machine(ctx: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
92
+
93
+ export { UserDefinedContext as Context, connect, machine };