@destyler/tooltip 0.0.6 → 0.0.7-beta.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,5 +1,146 @@
1
- export { a as TooltipArrow, b as TooltipArrowProps, c as TooltipContent, f as TooltipContentProps, g as TooltipPortal, i as TooltipPortalProps, j as TooltipProvider, l as TooltipProviderProps, m as TooltipRoot, p as TooltipRootProps, q as TooltipTrigger, s as TooltipTriggerProps, t as tooltipArrowProps, e as tooltipContentProps, h as tooltipPortalProps, k as tooltipProviderProps, n as tooltipRootProps, r as tooltipTriggerProps } from './shared/tooltip.6a045e60.mjs';
2
- import '@destyler/primitive';
3
- import 'vue';
4
- import '@destyler/shared';
5
- import '@vue/shared';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
3
+ import * as _zag_js_core from '@zag-js/core';
4
+ import { Machine, StateMachine } from '@zag-js/core';
5
+ import { PositioningOptions, Placement } from '@zag-js/popper';
6
+ export { Placement, PositioningOptions } from '@zag-js/popper';
7
+
8
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content">;
9
+
10
+ interface OpenChangeDetails {
11
+ open: boolean;
12
+ }
13
+ type ElementIds = Partial<{
14
+ trigger: string;
15
+ content: string;
16
+ arrow: string;
17
+ positioner: string;
18
+ }>;
19
+ interface PublicContext extends DirectionProperty, CommonProperties {
20
+ /**
21
+ * The ids of the elements in the tooltip. Useful for composition.
22
+ */
23
+ 'ids'?: ElementIds | undefined;
24
+ /**
25
+ * The `id` of the tooltip.
26
+ */
27
+ 'id': string;
28
+ /**
29
+ * The open delay of the tooltip.
30
+ * @default 1000
31
+ */
32
+ 'openDelay': number;
33
+ /**
34
+ * The close delay of the tooltip.
35
+ * @default 500
36
+ */
37
+ 'closeDelay': number;
38
+ /**
39
+ * Whether to close the tooltip on pointerdown.
40
+ * @default true
41
+ */
42
+ 'closeOnPointerDown': boolean;
43
+ /**
44
+ * Whether to close the tooltip when the Escape key is pressed.
45
+ * @default true
46
+ */
47
+ 'closeOnEscape'?: boolean | undefined;
48
+ /**
49
+ * Whether the tooltip should close on scroll
50
+ * @default true
51
+ */
52
+ 'closeOnScroll'?: boolean | undefined;
53
+ /**
54
+ * Whether the tooltip should close on click
55
+ * @default true
56
+ */
57
+ 'closeOnClick'?: boolean | undefined;
58
+ /**
59
+ * Whether the tooltip's content is interactive.
60
+ * In this mode, the tooltip will remain open when user hovers over the content.
61
+ * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
62
+ *
63
+ * @default false
64
+ */
65
+ 'interactive': boolean;
66
+ /**
67
+ * Function called when the tooltip is opened.
68
+ */
69
+ 'onOpenChange'?: (details: OpenChangeDetails) => void;
70
+ /**
71
+ * Custom label for the tooltip.
72
+ */
73
+ 'aria-label'?: string | undefined;
74
+ /**
75
+ * The user provided options used to position the popover content
76
+ */
77
+ 'positioning': PositioningOptions;
78
+ /**
79
+ * Whether the tooltip is disabled
80
+ */
81
+ 'disabled'?: boolean | undefined;
82
+ /**
83
+ * Whether the tooltip is open
84
+ */
85
+ 'open'?: boolean | undefined;
86
+ /**
87
+ * Whether the tooltip is controlled by the user
88
+ */
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
+ * @internal
101
+ * The computed placement of the tooltip.
102
+ */
103
+ currentPlacement?: Placement | undefined;
104
+ /**
105
+ * @internal
106
+ * Whether the pointermove already opened the tooltip.
107
+ */
108
+ hasPointerMoveOpened?: boolean | undefined;
109
+ }
110
+ interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
111
+ }
112
+ interface MachineState {
113
+ value: 'opening' | 'open' | 'closing' | 'closed';
114
+ tags: 'open' | 'closed';
115
+ }
116
+ type State = StateMachine.State<MachineContext, MachineState>;
117
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
118
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
119
+ interface MachineApi<T extends PropTypes = PropTypes> {
120
+ /**
121
+ * Whether the tooltip is open.
122
+ */
123
+ open: boolean;
124
+ /**
125
+ * Function to open the tooltip.
126
+ */
127
+ setOpen: (open: boolean) => void;
128
+ /**
129
+ * Function to reposition the popover
130
+ */
131
+ reposition: (options?: Partial<PositioningOptions>) => void;
132
+ getTriggerProps: () => T['button'];
133
+ getArrowProps: () => T['element'];
134
+ getArrowTipProps: () => T['element'];
135
+ getPositionerProps: () => T['element'];
136
+ getContentProps: () => T['element'];
137
+ }
138
+
139
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
140
+
141
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
142
+
143
+ declare const props: ("ids" | "id" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open" | "open.controlled" | "dir" | "getRootNode")[];
144
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "id" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open" | "open.controlled" | "dir" | "getRootNode">];
145
+
146
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,146 @@
1
- export { a as TooltipArrow, b as TooltipArrowProps, c as TooltipContent, f as TooltipContentProps, g as TooltipPortal, i as TooltipPortalProps, j as TooltipProvider, l as TooltipProviderProps, m as TooltipRoot, p as TooltipRootProps, q as TooltipTrigger, s as TooltipTriggerProps, t as tooltipArrowProps, e as tooltipContentProps, h as tooltipPortalProps, k as tooltipProviderProps, n as tooltipRootProps, r as tooltipTriggerProps } from './shared/tooltip.6a045e60.js';
2
- import '@destyler/primitive';
3
- import 'vue';
4
- import '@destyler/shared';
5
- import '@vue/shared';
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
3
+ import * as _zag_js_core from '@zag-js/core';
4
+ import { Machine, StateMachine } from '@zag-js/core';
5
+ import { PositioningOptions, Placement } from '@zag-js/popper';
6
+ export { Placement, PositioningOptions } from '@zag-js/popper';
7
+
8
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content">;
9
+
10
+ interface OpenChangeDetails {
11
+ open: boolean;
12
+ }
13
+ type ElementIds = Partial<{
14
+ trigger: string;
15
+ content: string;
16
+ arrow: string;
17
+ positioner: string;
18
+ }>;
19
+ interface PublicContext extends DirectionProperty, CommonProperties {
20
+ /**
21
+ * The ids of the elements in the tooltip. Useful for composition.
22
+ */
23
+ 'ids'?: ElementIds | undefined;
24
+ /**
25
+ * The `id` of the tooltip.
26
+ */
27
+ 'id': string;
28
+ /**
29
+ * The open delay of the tooltip.
30
+ * @default 1000
31
+ */
32
+ 'openDelay': number;
33
+ /**
34
+ * The close delay of the tooltip.
35
+ * @default 500
36
+ */
37
+ 'closeDelay': number;
38
+ /**
39
+ * Whether to close the tooltip on pointerdown.
40
+ * @default true
41
+ */
42
+ 'closeOnPointerDown': boolean;
43
+ /**
44
+ * Whether to close the tooltip when the Escape key is pressed.
45
+ * @default true
46
+ */
47
+ 'closeOnEscape'?: boolean | undefined;
48
+ /**
49
+ * Whether the tooltip should close on scroll
50
+ * @default true
51
+ */
52
+ 'closeOnScroll'?: boolean | undefined;
53
+ /**
54
+ * Whether the tooltip should close on click
55
+ * @default true
56
+ */
57
+ 'closeOnClick'?: boolean | undefined;
58
+ /**
59
+ * Whether the tooltip's content is interactive.
60
+ * In this mode, the tooltip will remain open when user hovers over the content.
61
+ * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
62
+ *
63
+ * @default false
64
+ */
65
+ 'interactive': boolean;
66
+ /**
67
+ * Function called when the tooltip is opened.
68
+ */
69
+ 'onOpenChange'?: (details: OpenChangeDetails) => void;
70
+ /**
71
+ * Custom label for the tooltip.
72
+ */
73
+ 'aria-label'?: string | undefined;
74
+ /**
75
+ * The user provided options used to position the popover content
76
+ */
77
+ 'positioning': PositioningOptions;
78
+ /**
79
+ * Whether the tooltip is disabled
80
+ */
81
+ 'disabled'?: boolean | undefined;
82
+ /**
83
+ * Whether the tooltip is open
84
+ */
85
+ 'open'?: boolean | undefined;
86
+ /**
87
+ * Whether the tooltip is controlled by the user
88
+ */
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
+ * @internal
101
+ * The computed placement of the tooltip.
102
+ */
103
+ currentPlacement?: Placement | undefined;
104
+ /**
105
+ * @internal
106
+ * Whether the pointermove already opened the tooltip.
107
+ */
108
+ hasPointerMoveOpened?: boolean | undefined;
109
+ }
110
+ interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
111
+ }
112
+ interface MachineState {
113
+ value: 'opening' | 'open' | 'closing' | 'closed';
114
+ tags: 'open' | 'closed';
115
+ }
116
+ type State = StateMachine.State<MachineContext, MachineState>;
117
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
118
+ type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
119
+ interface MachineApi<T extends PropTypes = PropTypes> {
120
+ /**
121
+ * Whether the tooltip is open.
122
+ */
123
+ open: boolean;
124
+ /**
125
+ * Function to open the tooltip.
126
+ */
127
+ setOpen: (open: boolean) => void;
128
+ /**
129
+ * Function to reposition the popover
130
+ */
131
+ reposition: (options?: Partial<PositioningOptions>) => void;
132
+ getTriggerProps: () => T['button'];
133
+ getArrowProps: () => T['element'];
134
+ getArrowTipProps: () => T['element'];
135
+ getPositionerProps: () => T['element'];
136
+ getContentProps: () => T['element'];
137
+ }
138
+
139
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
140
+
141
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
142
+
143
+ declare const props: ("ids" | "id" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open" | "open.controlled" | "dir" | "getRootNode")[];
144
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "id" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open" | "open.controlled" | "dir" | "getRootNode">];
145
+
146
+ export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };