@destyler/tooltip 0.0.7-beta.7 → 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.
- package/dist/index.d.ts +132 -129
- package/dist/index.js +491 -0
- package/package.json +13 -18
- package/dist/index.cjs +0 -496
- package/dist/index.d.cts +0 -146
- package/dist/index.d.mts +0 -146
- package/dist/index.mjs +0 -490
package/dist/index.d.ts
CHANGED
|
@@ -1,146 +1,149 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export { Placement, PositioningOptions } from '@zag-js/popper';
|
|
7
|
-
|
|
8
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content">;
|
|
1
|
+
import * as _destyler_anatomy0 from "@destyler/anatomy";
|
|
2
|
+
import { Placement, PositioningOptions } from "@destyler/popper";
|
|
3
|
+
import * as _destyler_xstate0 from "@destyler/xstate";
|
|
4
|
+
import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
|
|
5
|
+
import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
|
|
9
6
|
|
|
7
|
+
//#region src/anatomy.d.ts
|
|
8
|
+
declare const anatomy: _destyler_anatomy0.AnatomyInstance<"trigger" | "content" | "arrow" | "positioner" | "arrowTip">;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/types.d.ts
|
|
10
11
|
interface OpenChangeDetails {
|
|
11
|
-
|
|
12
|
+
open: boolean;
|
|
12
13
|
}
|
|
13
14
|
type ElementIds = Partial<{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
trigger: string;
|
|
16
|
+
content: string;
|
|
17
|
+
arrow: string;
|
|
18
|
+
positioner: string;
|
|
18
19
|
}>;
|
|
19
20
|
interface PublicContext extends DirectionProperty, CommonProperties {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The ids of the elements in the tooltip. Useful for composition.
|
|
23
|
+
*/
|
|
24
|
+
'ids'?: ElementIds | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The `id` of the tooltip.
|
|
27
|
+
*/
|
|
28
|
+
'id': string;
|
|
29
|
+
/**
|
|
30
|
+
* The open delay of the tooltip.
|
|
31
|
+
* @default 1000
|
|
32
|
+
*/
|
|
33
|
+
'openDelay': number;
|
|
34
|
+
/**
|
|
35
|
+
* The close delay of the tooltip.
|
|
36
|
+
* @default 500
|
|
37
|
+
*/
|
|
38
|
+
'closeDelay': number;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to close the tooltip on pointerdown.
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
'closeOnPointerDown': boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to close the tooltip when the Escape key is pressed.
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
'closeOnEscape'?: boolean | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the tooltip should close on scroll
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
'closeOnScroll'?: boolean | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the tooltip should close on click
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
'closeOnClick'?: boolean | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the tooltip's content is interactive.
|
|
61
|
+
* In this mode, the tooltip will remain open when user hovers over the content.
|
|
62
|
+
* @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
|
|
63
|
+
*
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
'interactive': boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Function called when the tooltip is opened.
|
|
69
|
+
*/
|
|
70
|
+
'onOpenChange'?: (details: OpenChangeDetails) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Custom label for the tooltip.
|
|
73
|
+
*/
|
|
74
|
+
'aria-label'?: string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The user provided options used to position the popover content
|
|
77
|
+
*/
|
|
78
|
+
'positioning': PositioningOptions;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the tooltip is disabled
|
|
81
|
+
*/
|
|
82
|
+
'disabled'?: boolean | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the tooltip is open
|
|
85
|
+
*/
|
|
86
|
+
'open'?: boolean | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Whether the tooltip is controlled by the user
|
|
89
|
+
*/
|
|
90
|
+
'open.controlled'?: boolean | undefined;
|
|
90
91
|
}
|
|
91
92
|
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
92
93
|
type ComputedContext = Readonly<{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
/**
|
|
95
|
+
* @computed Whether an `aria-label` is set.
|
|
96
|
+
*/
|
|
97
|
+
hasAriaLabel: boolean;
|
|
97
98
|
}>;
|
|
98
99
|
interface PrivateContext {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
|
|
100
|
+
/**
|
|
101
|
+
* @internal
|
|
102
|
+
* The computed placement of the tooltip.
|
|
103
|
+
*/
|
|
104
|
+
currentPlacement?: Placement | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* @internal
|
|
107
|
+
* Whether the pointermove already opened the tooltip.
|
|
108
|
+
*/
|
|
109
|
+
hasPointerMoveOpened?: boolean | undefined;
|
|
111
110
|
}
|
|
111
|
+
interface MachineContext extends PublicContext, ComputedContext, PrivateContext {}
|
|
112
112
|
interface MachineState {
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
value: 'opening' | 'open' | 'closing' | 'closed';
|
|
114
|
+
tags: 'open' | 'closed';
|
|
115
115
|
}
|
|
116
|
-
type State =
|
|
117
|
-
type Send =
|
|
118
|
-
type Service = Machine<MachineContext, MachineState,
|
|
116
|
+
type State = XState<MachineContext, MachineState>;
|
|
117
|
+
type Send = XSend<AnyEventObject>;
|
|
118
|
+
type Service = Machine<MachineContext, MachineState, AnyEventObject>;
|
|
119
119
|
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
137
|
}
|
|
138
|
-
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/connect.d.ts
|
|
139
140
|
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/machine.d.ts
|
|
143
|
+
declare function machine(userContext: UserDefinedContext): _destyler_xstate0.Machine<MachineContext, MachineState, _destyler_xstate0.AnyEventObject>;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/props.d.ts
|
|
146
|
+
declare const props: ("open" | "id" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open.controlled" | "dir" | "getRootNode")[];
|
|
147
|
+
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "id" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open.controlled" | "dir" | "getRootNode">];
|
|
148
|
+
//#endregion
|
|
149
|
+
export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Placement, type PositioningOptions, type Service, anatomy, connect, machine, props, splitProps };
|