@zag-js/tooltip 0.82.2 → 1.0.1

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/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
3
2
  import * as _zag_js_core from '@zag-js/core';
4
- import { Machine, StateMachine } from '@zag-js/core';
5
- import { PositioningOptions } from '@zag-js/popper';
3
+ import { Service, Machine, EventObject } from '@zag-js/core';
4
+ import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
5
+ import { PositioningOptions, Placement } from '@zag-js/popper';
6
6
  export { Placement, PositioningOptions } from '@zag-js/popper';
7
7
 
8
8
  declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content">;
@@ -16,30 +16,26 @@ type ElementIds = Partial<{
16
16
  arrow: string;
17
17
  positioner: string;
18
18
  }>;
19
- interface PublicContext extends DirectionProperty, CommonProperties {
19
+ interface TooltipProps extends DirectionProperty, CommonProperties {
20
20
  /**
21
21
  * The ids of the elements in the tooltip. Useful for composition.
22
22
  */
23
23
  ids?: ElementIds | undefined;
24
- /**
25
- * The `id` of the tooltip.
26
- */
27
- id: string;
28
24
  /**
29
25
  * The open delay of the tooltip.
30
26
  * @default 1000
31
27
  */
32
- openDelay: number;
28
+ openDelay?: number | undefined;
33
29
  /**
34
30
  * The close delay of the tooltip.
35
31
  * @default 500
36
32
  */
37
- closeDelay: number;
33
+ closeDelay?: number | undefined;
38
34
  /**
39
35
  * Whether to close the tooltip on pointerdown.
40
36
  * @default true
41
37
  */
42
- closeOnPointerDown: boolean;
38
+ closeOnPointerDown?: boolean | undefined;
43
39
  /**
44
40
  * Whether to close the tooltip when the Escape key is pressed.
45
41
  * @default true
@@ -62,11 +58,11 @@ interface PublicContext extends DirectionProperty, CommonProperties {
62
58
  *
63
59
  * @default false
64
60
  */
65
- interactive: boolean;
61
+ interactive?: boolean | undefined;
66
62
  /**
67
63
  * Function called when the tooltip is opened.
68
64
  */
69
- onOpenChange?(details: OpenChangeDetails): void;
65
+ onOpenChange?: ((details: OpenChangeDetails) => void) | undefined;
70
66
  /**
71
67
  * Custom label for the tooltip.
72
68
  */
@@ -74,39 +70,37 @@ interface PublicContext extends DirectionProperty, CommonProperties {
74
70
  /**
75
71
  * The user provided options used to position the popover content
76
72
  */
77
- positioning: PositioningOptions;
73
+ positioning?: PositioningOptions | undefined;
78
74
  /**
79
75
  * Whether the tooltip is disabled
80
76
  */
81
77
  disabled?: boolean | undefined;
82
78
  /**
83
- * Whether the tooltip is open
79
+ * The controlled open state of the tooltip
84
80
  */
85
81
  open?: boolean | undefined;
86
82
  /**
87
- * Whether the tooltip is controlled by the user
83
+ * The initial open state of the tooltip when rendered.
84
+ * Use when you don't need to control the open state of the tooltip.
88
85
  */
89
- "open.controlled"?: boolean | undefined;
90
- }
91
- type UserDefinedContext = RequiredBy<PublicContext, "id">;
92
- type ComputedContext = Readonly<{
93
- /**
94
- * @computed Whether an `aria-label` is set.
95
- */
96
- hasAriaLabel: boolean;
97
- }>;
98
- interface PrivateContext {
99
- }
100
- interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
86
+ defaultOpen?: boolean | undefined;
101
87
  }
102
- interface MachineState {
103
- value: "opening" | "open" | "closing" | "closed";
104
- tags: "open" | "closed";
88
+ type PropsWithDefault = "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "id";
89
+ interface TooltipSchema {
90
+ state: "open" | "closed" | "opening" | "closing";
91
+ props: RequiredBy<TooltipProps, PropsWithDefault>;
92
+ context: {
93
+ currentPlacement: Placement | undefined;
94
+ hasPointerMoveOpened: boolean;
95
+ };
96
+ event: EventObject;
97
+ action: string;
98
+ effect: string;
99
+ guard: string;
105
100
  }
106
- type State = StateMachine.State<MachineContext, MachineState>;
107
- type Send = StateMachine.Send<StateMachine.AnyEventObject>;
108
- type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
109
- interface MachineApi<T extends PropTypes = PropTypes> {
101
+ type TooltipService = Service<TooltipSchema>;
102
+ type TooltipMachine = Machine<TooltipSchema>;
103
+ interface TooltipApi<T extends PropTypes = PropTypes> {
110
104
  /**
111
105
  * Whether the tooltip is open.
112
106
  */
@@ -126,11 +120,11 @@ interface MachineApi<T extends PropTypes = PropTypes> {
126
120
  getContentProps(): T["element"];
127
121
  }
128
122
 
129
- declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
123
+ declare function connect<P extends PropTypes>(service: Service<TooltipSchema>, normalize: NormalizeProps<P>): TooltipApi<P>;
130
124
 
131
- declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
125
+ declare const machine: _zag_js_core.Machine<TooltipSchema>;
132
126
 
133
- declare const props: ("open" | "disabled" | "dir" | "id" | "aria-label" | "getRootNode" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "positioning" | "open.controlled")[];
134
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "disabled" | "dir" | "id" | "aria-label" | "getRootNode" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "positioning" | "open.controlled">];
127
+ declare const props: (keyof TooltipProps)[];
128
+ declare const splitProps: <Props extends Partial<TooltipProps>>(props: Props) => [Partial<TooltipProps>, Omit<Props, keyof TooltipProps>];
135
129
 
136
- export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };
130
+ export { type TooltipApi as Api, type ElementIds, type TooltipMachine as Machine, type OpenChangeDetails, type TooltipProps as Props, type TooltipService as Service, anatomy, connect, machine, props, splitProps };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
3
2
  import * as _zag_js_core from '@zag-js/core';
4
- import { Machine, StateMachine } from '@zag-js/core';
5
- import { PositioningOptions } from '@zag-js/popper';
3
+ import { Service, Machine, EventObject } from '@zag-js/core';
4
+ import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
5
+ import { PositioningOptions, Placement } from '@zag-js/popper';
6
6
  export { Placement, PositioningOptions } from '@zag-js/popper';
7
7
 
8
8
  declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content">;
@@ -16,30 +16,26 @@ type ElementIds = Partial<{
16
16
  arrow: string;
17
17
  positioner: string;
18
18
  }>;
19
- interface PublicContext extends DirectionProperty, CommonProperties {
19
+ interface TooltipProps extends DirectionProperty, CommonProperties {
20
20
  /**
21
21
  * The ids of the elements in the tooltip. Useful for composition.
22
22
  */
23
23
  ids?: ElementIds | undefined;
24
- /**
25
- * The `id` of the tooltip.
26
- */
27
- id: string;
28
24
  /**
29
25
  * The open delay of the tooltip.
30
26
  * @default 1000
31
27
  */
32
- openDelay: number;
28
+ openDelay?: number | undefined;
33
29
  /**
34
30
  * The close delay of the tooltip.
35
31
  * @default 500
36
32
  */
37
- closeDelay: number;
33
+ closeDelay?: number | undefined;
38
34
  /**
39
35
  * Whether to close the tooltip on pointerdown.
40
36
  * @default true
41
37
  */
42
- closeOnPointerDown: boolean;
38
+ closeOnPointerDown?: boolean | undefined;
43
39
  /**
44
40
  * Whether to close the tooltip when the Escape key is pressed.
45
41
  * @default true
@@ -62,11 +58,11 @@ interface PublicContext extends DirectionProperty, CommonProperties {
62
58
  *
63
59
  * @default false
64
60
  */
65
- interactive: boolean;
61
+ interactive?: boolean | undefined;
66
62
  /**
67
63
  * Function called when the tooltip is opened.
68
64
  */
69
- onOpenChange?(details: OpenChangeDetails): void;
65
+ onOpenChange?: ((details: OpenChangeDetails) => void) | undefined;
70
66
  /**
71
67
  * Custom label for the tooltip.
72
68
  */
@@ -74,39 +70,37 @@ interface PublicContext extends DirectionProperty, CommonProperties {
74
70
  /**
75
71
  * The user provided options used to position the popover content
76
72
  */
77
- positioning: PositioningOptions;
73
+ positioning?: PositioningOptions | undefined;
78
74
  /**
79
75
  * Whether the tooltip is disabled
80
76
  */
81
77
  disabled?: boolean | undefined;
82
78
  /**
83
- * Whether the tooltip is open
79
+ * The controlled open state of the tooltip
84
80
  */
85
81
  open?: boolean | undefined;
86
82
  /**
87
- * Whether the tooltip is controlled by the user
83
+ * The initial open state of the tooltip when rendered.
84
+ * Use when you don't need to control the open state of the tooltip.
88
85
  */
89
- "open.controlled"?: boolean | undefined;
90
- }
91
- type UserDefinedContext = RequiredBy<PublicContext, "id">;
92
- type ComputedContext = Readonly<{
93
- /**
94
- * @computed Whether an `aria-label` is set.
95
- */
96
- hasAriaLabel: boolean;
97
- }>;
98
- interface PrivateContext {
99
- }
100
- interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
86
+ defaultOpen?: boolean | undefined;
101
87
  }
102
- interface MachineState {
103
- value: "opening" | "open" | "closing" | "closed";
104
- tags: "open" | "closed";
88
+ type PropsWithDefault = "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "id";
89
+ interface TooltipSchema {
90
+ state: "open" | "closed" | "opening" | "closing";
91
+ props: RequiredBy<TooltipProps, PropsWithDefault>;
92
+ context: {
93
+ currentPlacement: Placement | undefined;
94
+ hasPointerMoveOpened: boolean;
95
+ };
96
+ event: EventObject;
97
+ action: string;
98
+ effect: string;
99
+ guard: string;
105
100
  }
106
- type State = StateMachine.State<MachineContext, MachineState>;
107
- type Send = StateMachine.Send<StateMachine.AnyEventObject>;
108
- type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
109
- interface MachineApi<T extends PropTypes = PropTypes> {
101
+ type TooltipService = Service<TooltipSchema>;
102
+ type TooltipMachine = Machine<TooltipSchema>;
103
+ interface TooltipApi<T extends PropTypes = PropTypes> {
110
104
  /**
111
105
  * Whether the tooltip is open.
112
106
  */
@@ -126,11 +120,11 @@ interface MachineApi<T extends PropTypes = PropTypes> {
126
120
  getContentProps(): T["element"];
127
121
  }
128
122
 
129
- declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
123
+ declare function connect<P extends PropTypes>(service: Service<TooltipSchema>, normalize: NormalizeProps<P>): TooltipApi<P>;
130
124
 
131
- declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
125
+ declare const machine: _zag_js_core.Machine<TooltipSchema>;
132
126
 
133
- declare const props: ("open" | "disabled" | "dir" | "id" | "aria-label" | "getRootNode" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "positioning" | "open.controlled")[];
134
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "disabled" | "dir" | "id" | "aria-label" | "getRootNode" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "positioning" | "open.controlled">];
127
+ declare const props: (keyof TooltipProps)[];
128
+ declare const splitProps: <Props extends Partial<TooltipProps>>(props: Props) => [Partial<TooltipProps>, Omit<Props, keyof TooltipProps>];
135
129
 
136
- export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };
130
+ export { type TooltipApi as Api, type ElementIds, type TooltipMachine as Machine, type OpenChangeDetails, type TooltipProps as Props, type TooltipService as Service, anatomy, connect, machine, props, splitProps };