@destyler/hover-card 0.0.7-beta.5 → 0.0.7-beta.9
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 +87 -83
- package/dist/index.js +330 -0
- package/package.json +13 -17
- package/dist/index.cjs +0 -341
- package/dist/index.d.cts +0 -100
- package/dist/index.d.mts +0 -100
- package/dist/index.mjs +0 -335
package/dist/index.cjs
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const anatomy$1 = require('@zag-js/anatomy');
|
|
4
|
-
const popper = require('@zag-js/popper');
|
|
5
|
-
const domQuery = require('@zag-js/dom-query');
|
|
6
|
-
const core = require('@zag-js/core');
|
|
7
|
-
const dismissable = require('@zag-js/dismissable');
|
|
8
|
-
const utils = require('@zag-js/utils');
|
|
9
|
-
const types = require('@zag-js/types');
|
|
10
|
-
|
|
11
|
-
const anatomy = anatomy$1.createAnatomy("hoverCard").parts("arrow", "arrowTip", "trigger", "positioner", "content");
|
|
12
|
-
const parts = anatomy.build();
|
|
13
|
-
|
|
14
|
-
const dom = domQuery.createScope({
|
|
15
|
-
getTriggerId: (ctx) => ctx.ids?.trigger ?? `hover-card:${ctx.id}:trigger`,
|
|
16
|
-
getContentId: (ctx) => ctx.ids?.content ?? `hover-card:${ctx.id}:content`,
|
|
17
|
-
getPositionerId: (ctx) => ctx.ids?.positioner ?? `hover-card:${ctx.id}:popper`,
|
|
18
|
-
getArrowId: (ctx) => ctx.ids?.arrow ?? `hover-card:${ctx.id}:arrow`,
|
|
19
|
-
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
20
|
-
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
21
|
-
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx))
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
function connect(state, send, normalize) {
|
|
25
|
-
const open = state.hasTag("open");
|
|
26
|
-
const popperStyles = popper.getPlacementStyles({
|
|
27
|
-
...state.context.positioning,
|
|
28
|
-
placement: state.context.currentPlacement
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
open,
|
|
32
|
-
setOpen(nextOpen) {
|
|
33
|
-
if (nextOpen === open)
|
|
34
|
-
return;
|
|
35
|
-
send(nextOpen ? "OPEN" : "CLOSE");
|
|
36
|
-
},
|
|
37
|
-
reposition(options = {}) {
|
|
38
|
-
send({ type: "POSITIONING.SET", options });
|
|
39
|
-
},
|
|
40
|
-
getArrowProps() {
|
|
41
|
-
return normalize.element({
|
|
42
|
-
id: dom.getArrowId(state.context),
|
|
43
|
-
...parts.arrow.attrs,
|
|
44
|
-
dir: state.context.dir,
|
|
45
|
-
style: popperStyles.arrow
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
getArrowTipProps() {
|
|
49
|
-
return normalize.element({
|
|
50
|
-
...parts.arrowTip.attrs,
|
|
51
|
-
dir: state.context.dir,
|
|
52
|
-
style: popperStyles.arrowTip
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
getTriggerProps() {
|
|
56
|
-
return normalize.element({
|
|
57
|
-
...parts.trigger.attrs,
|
|
58
|
-
"dir": state.context.dir,
|
|
59
|
-
"data-placement": state.context.currentPlacement,
|
|
60
|
-
"id": dom.getTriggerId(state.context),
|
|
61
|
-
"data-state": open ? "open" : "closed",
|
|
62
|
-
onPointerEnter(event) {
|
|
63
|
-
if (event.pointerType === "touch")
|
|
64
|
-
return;
|
|
65
|
-
send({ type: "POINTER_ENTER", src: "trigger" });
|
|
66
|
-
},
|
|
67
|
-
onPointerLeave(event) {
|
|
68
|
-
if (event.pointerType === "touch")
|
|
69
|
-
return;
|
|
70
|
-
send({ type: "POINTER_LEAVE", src: "trigger" });
|
|
71
|
-
},
|
|
72
|
-
onFocus() {
|
|
73
|
-
send("TRIGGER_FOCUS");
|
|
74
|
-
},
|
|
75
|
-
onBlur() {
|
|
76
|
-
send("TRIGGER_BLUR");
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
getPositionerProps() {
|
|
81
|
-
return normalize.element({
|
|
82
|
-
id: dom.getPositionerId(state.context),
|
|
83
|
-
...parts.positioner.attrs,
|
|
84
|
-
dir: state.context.dir,
|
|
85
|
-
style: popperStyles.floating
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
getContentProps() {
|
|
89
|
-
return normalize.element({
|
|
90
|
-
...parts.content.attrs,
|
|
91
|
-
"dir": state.context.dir,
|
|
92
|
-
"id": dom.getContentId(state.context),
|
|
93
|
-
"hidden": !open,
|
|
94
|
-
"data-state": open ? "open" : "closed",
|
|
95
|
-
"data-placement": state.context.currentPlacement,
|
|
96
|
-
onPointerEnter(event) {
|
|
97
|
-
if (event.pointerType === "touch")
|
|
98
|
-
return;
|
|
99
|
-
send({ type: "POINTER_ENTER", src: "content" });
|
|
100
|
-
},
|
|
101
|
-
onPointerLeave(event) {
|
|
102
|
-
if (event.pointerType === "touch")
|
|
103
|
-
return;
|
|
104
|
-
send({ type: "POINTER_LEAVE", src: "content" });
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const { not, and } = core.guards;
|
|
112
|
-
function machine(userContext) {
|
|
113
|
-
const ctx = utils.compact(userContext);
|
|
114
|
-
return core.createMachine(
|
|
115
|
-
{
|
|
116
|
-
id: "hover-card",
|
|
117
|
-
initial: ctx.open ? "open" : "closed",
|
|
118
|
-
context: {
|
|
119
|
-
openDelay: 700,
|
|
120
|
-
closeDelay: 300,
|
|
121
|
-
currentPlacement: void 0,
|
|
122
|
-
...ctx,
|
|
123
|
-
positioning: {
|
|
124
|
-
placement: "bottom",
|
|
125
|
-
...ctx.positioning
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
watch: {
|
|
129
|
-
open: ["toggleVisibility"]
|
|
130
|
-
},
|
|
131
|
-
states: {
|
|
132
|
-
closed: {
|
|
133
|
-
tags: ["closed"],
|
|
134
|
-
entry: ["clearIsPointer"],
|
|
135
|
-
on: {
|
|
136
|
-
"CONTROLLED.OPEN": "open",
|
|
137
|
-
"POINTER_ENTER": {
|
|
138
|
-
target: "opening",
|
|
139
|
-
actions: ["setIsPointer"]
|
|
140
|
-
},
|
|
141
|
-
"TRIGGER_FOCUS": "opening",
|
|
142
|
-
"OPEN": "opening"
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
opening: {
|
|
146
|
-
tags: ["closed"],
|
|
147
|
-
after: {
|
|
148
|
-
OPEN_DELAY: [
|
|
149
|
-
{
|
|
150
|
-
guard: "isOpenControlled",
|
|
151
|
-
actions: ["invokeOnOpen"]
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
target: "open",
|
|
155
|
-
actions: ["invokeOnOpen"]
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
},
|
|
159
|
-
on: {
|
|
160
|
-
"CONTROLLED.OPEN": "open",
|
|
161
|
-
"POINTER_LEAVE": [
|
|
162
|
-
{
|
|
163
|
-
guard: "isOpenControlled",
|
|
164
|
-
actions: ["invokeOnClose"]
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
target: "closed",
|
|
168
|
-
actions: ["invokeOnClose"]
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
"TRIGGER_BLUR": [
|
|
172
|
-
{
|
|
173
|
-
guard: and("isOpenControlled", not("isPointer")),
|
|
174
|
-
actions: ["invokeOnClose"]
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
guard: not("isPointer"),
|
|
178
|
-
target: "closed",
|
|
179
|
-
actions: ["invokeOnClose"]
|
|
180
|
-
}
|
|
181
|
-
],
|
|
182
|
-
"CLOSE": [
|
|
183
|
-
{
|
|
184
|
-
guard: "isOpenControlled",
|
|
185
|
-
actions: ["invokeOnClose"]
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
target: "closed",
|
|
189
|
-
actions: ["invokeOnClose"]
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
open: {
|
|
195
|
-
tags: ["open"],
|
|
196
|
-
activities: ["trackDismissableElement", "trackPositioning"],
|
|
197
|
-
on: {
|
|
198
|
-
"CONTROLLED.CLOSE": "closed",
|
|
199
|
-
"POINTER_ENTER": {
|
|
200
|
-
actions: ["setIsPointer"]
|
|
201
|
-
},
|
|
202
|
-
"POINTER_LEAVE": "closing",
|
|
203
|
-
"CLOSE": [
|
|
204
|
-
{
|
|
205
|
-
guard: "isOpenControlled",
|
|
206
|
-
actions: ["invokeOnClose"]
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
target: "closed",
|
|
210
|
-
actions: ["invokeOnClose"]
|
|
211
|
-
}
|
|
212
|
-
],
|
|
213
|
-
"TRIGGER_BLUR": [
|
|
214
|
-
{
|
|
215
|
-
guard: and("isOpenControlled", not("isPointer")),
|
|
216
|
-
actions: ["invokeOnClose"]
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
guard: not("isPointer"),
|
|
220
|
-
target: "closed",
|
|
221
|
-
actions: ["invokeOnClose"]
|
|
222
|
-
}
|
|
223
|
-
],
|
|
224
|
-
"POSITIONING.SET": {
|
|
225
|
-
actions: "reposition"
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
closing: {
|
|
230
|
-
tags: ["open"],
|
|
231
|
-
activities: ["trackPositioning"],
|
|
232
|
-
after: {
|
|
233
|
-
CLOSE_DELAY: [
|
|
234
|
-
{
|
|
235
|
-
guard: "isOpenControlled",
|
|
236
|
-
actions: ["invokeOnClose"]
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
target: "closed",
|
|
240
|
-
actions: ["invokeOnClose"]
|
|
241
|
-
}
|
|
242
|
-
]
|
|
243
|
-
},
|
|
244
|
-
on: {
|
|
245
|
-
"CONTROLLED.CLOSE": "closed",
|
|
246
|
-
"POINTER_ENTER": {
|
|
247
|
-
target: "open",
|
|
248
|
-
// no need to invokeOnOpen here because it's still open (but about to close)
|
|
249
|
-
actions: ["setIsPointer"]
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
guards: {
|
|
257
|
-
isPointer: (ctx2) => !!ctx2.isPointer,
|
|
258
|
-
isOpenControlled: (ctx2) => !!ctx2["open.controlled"]
|
|
259
|
-
},
|
|
260
|
-
activities: {
|
|
261
|
-
trackPositioning(ctx2) {
|
|
262
|
-
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
263
|
-
const getPositionerEl = () => dom.getPositionerEl(ctx2);
|
|
264
|
-
return popper.getPlacement(dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
265
|
-
...ctx2.positioning,
|
|
266
|
-
defer: true,
|
|
267
|
-
onComplete(data) {
|
|
268
|
-
ctx2.currentPlacement = data.placement;
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
},
|
|
272
|
-
trackDismissableElement(ctx2, _evt, { send }) {
|
|
273
|
-
const getContentEl = () => dom.getContentEl(ctx2);
|
|
274
|
-
return dismissable.trackDismissableElement(getContentEl, {
|
|
275
|
-
defer: true,
|
|
276
|
-
exclude: [dom.getTriggerEl(ctx2)],
|
|
277
|
-
onDismiss() {
|
|
278
|
-
send({ type: "CLOSE", src: "interact-outside" });
|
|
279
|
-
},
|
|
280
|
-
onFocusOutside(event) {
|
|
281
|
-
event.preventDefault();
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
actions: {
|
|
287
|
-
invokeOnClose(ctx2) {
|
|
288
|
-
ctx2.onOpenChange?.({ open: false });
|
|
289
|
-
},
|
|
290
|
-
invokeOnOpen(ctx2) {
|
|
291
|
-
ctx2.onOpenChange?.({ open: true });
|
|
292
|
-
},
|
|
293
|
-
setIsPointer(ctx2) {
|
|
294
|
-
ctx2.isPointer = true;
|
|
295
|
-
},
|
|
296
|
-
clearIsPointer(ctx2) {
|
|
297
|
-
ctx2.isPointer = false;
|
|
298
|
-
},
|
|
299
|
-
reposition(ctx2, evt) {
|
|
300
|
-
const getPositionerEl = () => dom.getPositionerEl(ctx2);
|
|
301
|
-
popper.getPlacement(dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
302
|
-
...ctx2.positioning,
|
|
303
|
-
...evt.options,
|
|
304
|
-
defer: true,
|
|
305
|
-
listeners: false,
|
|
306
|
-
onComplete(data) {
|
|
307
|
-
ctx2.currentPlacement = data.placement;
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
},
|
|
311
|
-
toggleVisibility(ctx2, evt, { send }) {
|
|
312
|
-
send({ type: ctx2.open ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE", previousEvent: evt });
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
delays: {
|
|
316
|
-
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
317
|
-
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const props = types.createProps()([
|
|
324
|
-
"closeDelay",
|
|
325
|
-
"dir",
|
|
326
|
-
"getRootNode",
|
|
327
|
-
"id",
|
|
328
|
-
"ids",
|
|
329
|
-
"onOpenChange",
|
|
330
|
-
"open.controlled",
|
|
331
|
-
"open",
|
|
332
|
-
"openDelay",
|
|
333
|
-
"positioning"
|
|
334
|
-
]);
|
|
335
|
-
const splitProps = utils.createSplitProps(props);
|
|
336
|
-
|
|
337
|
-
exports.anatomy = anatomy;
|
|
338
|
-
exports.connect = connect;
|
|
339
|
-
exports.machine = machine;
|
|
340
|
-
exports.props = props;
|
|
341
|
-
exports.splitProps = splitProps;
|
package/dist/index.d.cts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
3
|
-
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
-
import { StateMachine, Machine } 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<"arrow" | "arrowTip" | "trigger" | "positioner" | "content">;
|
|
9
|
-
|
|
10
|
-
interface OpenChangeDetails {
|
|
11
|
-
open: boolean;
|
|
12
|
-
}
|
|
13
|
-
type ElementIds = Partial<{
|
|
14
|
-
trigger: string;
|
|
15
|
-
content: string;
|
|
16
|
-
positioner: string;
|
|
17
|
-
arrow: string;
|
|
18
|
-
}>;
|
|
19
|
-
interface PublicContext extends DirectionProperty, CommonProperties {
|
|
20
|
-
/**
|
|
21
|
-
* The ids of the elements in the popover. Useful for composition.
|
|
22
|
-
*/
|
|
23
|
-
'ids'?: ElementIds | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Function called when the hover card opens or closes.
|
|
26
|
-
*/
|
|
27
|
-
'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* The duration from when the mouse enters the trigger until the hover card opens.
|
|
30
|
-
* @default 700
|
|
31
|
-
*/
|
|
32
|
-
'openDelay': number;
|
|
33
|
-
/**
|
|
34
|
-
* The duration from when the mouse leaves the trigger or content until the hover card closes.
|
|
35
|
-
* @default 300
|
|
36
|
-
*/
|
|
37
|
-
'closeDelay': number;
|
|
38
|
-
/**
|
|
39
|
-
* Whether the hover card is open
|
|
40
|
-
*/
|
|
41
|
-
'open'?: boolean | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the hover card is controlled by the user
|
|
44
|
-
*/
|
|
45
|
-
'open.controlled'?: boolean | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* The user provided options used to position the popover content
|
|
48
|
-
*/
|
|
49
|
-
'positioning': PositioningOptions;
|
|
50
|
-
}
|
|
51
|
-
interface PrivateContext {
|
|
52
|
-
/**
|
|
53
|
-
* @internal
|
|
54
|
-
* The computed placement of the tooltip.
|
|
55
|
-
*/
|
|
56
|
-
currentPlacement?: Placement | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* @internal
|
|
59
|
-
* Whether the hover card is open by pointer
|
|
60
|
-
*/
|
|
61
|
-
isPointer?: boolean | undefined;
|
|
62
|
-
}
|
|
63
|
-
type ComputedContext = Readonly<{}>;
|
|
64
|
-
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
65
|
-
type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
66
|
-
interface MachineState {
|
|
67
|
-
value: 'opening' | 'open' | 'closing' | 'closed';
|
|
68
|
-
tags: 'open' | 'closed';
|
|
69
|
-
}
|
|
70
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
71
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
72
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
73
|
-
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
74
|
-
/**
|
|
75
|
-
* Whether the hover card is open
|
|
76
|
-
*/
|
|
77
|
-
open: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Function to open the hover card
|
|
80
|
-
*/
|
|
81
|
-
setOpen: (open: boolean) => void;
|
|
82
|
-
/**
|
|
83
|
-
* Function to reposition the popover
|
|
84
|
-
*/
|
|
85
|
-
reposition: (options?: Partial<PositioningOptions>) => void;
|
|
86
|
-
getArrowProps: () => T['element'];
|
|
87
|
-
getArrowTipProps: () => T['element'];
|
|
88
|
-
getTriggerProps: () => T['element'];
|
|
89
|
-
getPositionerProps: () => T['element'];
|
|
90
|
-
getContentProps: () => T['element'];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
94
|
-
|
|
95
|
-
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
96
|
-
|
|
97
|
-
declare const props: ("ids" | "onOpenChange" | "openDelay" | "closeDelay" | "open" | "open.controlled" | "positioning" | "id" | "dir" | "getRootNode")[];
|
|
98
|
-
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "onOpenChange" | "openDelay" | "closeDelay" | "open" | "open.controlled" | "positioning" | "id" | "dir" | "getRootNode">];
|
|
99
|
-
|
|
100
|
-
export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };
|
package/dist/index.d.mts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
3
|
-
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
-
import { StateMachine, Machine } 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<"arrow" | "arrowTip" | "trigger" | "positioner" | "content">;
|
|
9
|
-
|
|
10
|
-
interface OpenChangeDetails {
|
|
11
|
-
open: boolean;
|
|
12
|
-
}
|
|
13
|
-
type ElementIds = Partial<{
|
|
14
|
-
trigger: string;
|
|
15
|
-
content: string;
|
|
16
|
-
positioner: string;
|
|
17
|
-
arrow: string;
|
|
18
|
-
}>;
|
|
19
|
-
interface PublicContext extends DirectionProperty, CommonProperties {
|
|
20
|
-
/**
|
|
21
|
-
* The ids of the elements in the popover. Useful for composition.
|
|
22
|
-
*/
|
|
23
|
-
'ids'?: ElementIds | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Function called when the hover card opens or closes.
|
|
26
|
-
*/
|
|
27
|
-
'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* The duration from when the mouse enters the trigger until the hover card opens.
|
|
30
|
-
* @default 700
|
|
31
|
-
*/
|
|
32
|
-
'openDelay': number;
|
|
33
|
-
/**
|
|
34
|
-
* The duration from when the mouse leaves the trigger or content until the hover card closes.
|
|
35
|
-
* @default 300
|
|
36
|
-
*/
|
|
37
|
-
'closeDelay': number;
|
|
38
|
-
/**
|
|
39
|
-
* Whether the hover card is open
|
|
40
|
-
*/
|
|
41
|
-
'open'?: boolean | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the hover card is controlled by the user
|
|
44
|
-
*/
|
|
45
|
-
'open.controlled'?: boolean | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* The user provided options used to position the popover content
|
|
48
|
-
*/
|
|
49
|
-
'positioning': PositioningOptions;
|
|
50
|
-
}
|
|
51
|
-
interface PrivateContext {
|
|
52
|
-
/**
|
|
53
|
-
* @internal
|
|
54
|
-
* The computed placement of the tooltip.
|
|
55
|
-
*/
|
|
56
|
-
currentPlacement?: Placement | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* @internal
|
|
59
|
-
* Whether the hover card is open by pointer
|
|
60
|
-
*/
|
|
61
|
-
isPointer?: boolean | undefined;
|
|
62
|
-
}
|
|
63
|
-
type ComputedContext = Readonly<{}>;
|
|
64
|
-
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
65
|
-
type MachineContext = PublicContext & PrivateContext & ComputedContext;
|
|
66
|
-
interface MachineState {
|
|
67
|
-
value: 'opening' | 'open' | 'closing' | 'closed';
|
|
68
|
-
tags: 'open' | 'closed';
|
|
69
|
-
}
|
|
70
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
71
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
72
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
73
|
-
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
74
|
-
/**
|
|
75
|
-
* Whether the hover card is open
|
|
76
|
-
*/
|
|
77
|
-
open: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Function to open the hover card
|
|
80
|
-
*/
|
|
81
|
-
setOpen: (open: boolean) => void;
|
|
82
|
-
/**
|
|
83
|
-
* Function to reposition the popover
|
|
84
|
-
*/
|
|
85
|
-
reposition: (options?: Partial<PositioningOptions>) => void;
|
|
86
|
-
getArrowProps: () => T['element'];
|
|
87
|
-
getArrowTipProps: () => T['element'];
|
|
88
|
-
getTriggerProps: () => T['element'];
|
|
89
|
-
getPositionerProps: () => T['element'];
|
|
90
|
-
getContentProps: () => T['element'];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
94
|
-
|
|
95
|
-
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
96
|
-
|
|
97
|
-
declare const props: ("ids" | "onOpenChange" | "openDelay" | "closeDelay" | "open" | "open.controlled" | "positioning" | "id" | "dir" | "getRootNode")[];
|
|
98
|
-
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "onOpenChange" | "openDelay" | "closeDelay" | "open" | "open.controlled" | "positioning" | "id" | "dir" | "getRootNode">];
|
|
99
|
-
|
|
100
|
-
export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Service, anatomy, connect, machine, props, splitProps };
|