@zag-js/tooltip 0.1.11 → 0.1.14
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.js +192 -189
- package/dist/index.mjs +192 -189
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -365,216 +365,219 @@ function connect(state, send, normalize) {
|
|
|
365
365
|
var import_core2 = require("@zag-js/core");
|
|
366
366
|
var import_popper2 = require("@zag-js/popper");
|
|
367
367
|
function machine(ctx) {
|
|
368
|
-
return (0, import_core2.createMachine)(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
},
|
|
384
|
-
computed: {
|
|
385
|
-
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
386
|
-
},
|
|
387
|
-
on: {
|
|
388
|
-
OPEN: "open",
|
|
389
|
-
CLOSE: "closed"
|
|
390
|
-
},
|
|
391
|
-
states: {
|
|
392
|
-
unknown: {
|
|
393
|
-
on: {
|
|
394
|
-
SETUP: "closed"
|
|
368
|
+
return (0, import_core2.createMachine)(
|
|
369
|
+
{
|
|
370
|
+
id: "tooltip",
|
|
371
|
+
initial: "unknown",
|
|
372
|
+
context: {
|
|
373
|
+
openDelay: 1e3,
|
|
374
|
+
closeDelay: 500,
|
|
375
|
+
closeOnPointerDown: true,
|
|
376
|
+
closeOnEsc: true,
|
|
377
|
+
interactive: true,
|
|
378
|
+
currentPlacement: void 0,
|
|
379
|
+
...ctx,
|
|
380
|
+
positioning: {
|
|
381
|
+
placement: "bottom",
|
|
382
|
+
...ctx.positioning
|
|
395
383
|
}
|
|
396
384
|
},
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
entry: ["clearGlobalId", "invokeOnClose"],
|
|
400
|
-
on: {
|
|
401
|
-
FOCUS: "open",
|
|
402
|
-
POINTER_ENTER: [
|
|
403
|
-
{
|
|
404
|
-
guard: "noVisibleTooltip",
|
|
405
|
-
target: "opening"
|
|
406
|
-
},
|
|
407
|
-
{ target: "open" }
|
|
408
|
-
]
|
|
409
|
-
}
|
|
385
|
+
computed: {
|
|
386
|
+
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
410
387
|
},
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
388
|
+
on: {
|
|
389
|
+
OPEN: "open",
|
|
390
|
+
CLOSE: "closed"
|
|
391
|
+
},
|
|
392
|
+
states: {
|
|
393
|
+
unknown: {
|
|
394
|
+
on: {
|
|
395
|
+
SETUP: "closed"
|
|
396
|
+
}
|
|
416
397
|
},
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
398
|
+
closed: {
|
|
399
|
+
tags: ["closed"],
|
|
400
|
+
entry: ["clearGlobalId", "invokeOnClose"],
|
|
401
|
+
on: {
|
|
402
|
+
FOCUS: "open",
|
|
403
|
+
POINTER_ENTER: [
|
|
404
|
+
{
|
|
405
|
+
guard: "noVisibleTooltip",
|
|
406
|
+
target: "opening"
|
|
407
|
+
},
|
|
408
|
+
{ target: "open" }
|
|
409
|
+
]
|
|
425
410
|
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
411
|
+
},
|
|
412
|
+
opening: {
|
|
413
|
+
tags: ["closed"],
|
|
414
|
+
activities: ["trackScroll", "trackPointerlockChange"],
|
|
415
|
+
after: {
|
|
416
|
+
OPEN_DELAY: "open"
|
|
417
|
+
},
|
|
418
|
+
on: {
|
|
419
|
+
POINTER_LEAVE: "closed",
|
|
420
|
+
BLUR: "closed",
|
|
421
|
+
SCROLL: "closed",
|
|
422
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
423
|
+
POINTER_DOWN: {
|
|
424
|
+
guard: "closeOnPointerDown",
|
|
425
|
+
target: "closed"
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
open: {
|
|
430
|
+
tags: ["open"],
|
|
431
|
+
activities: [
|
|
432
|
+
"trackEscapeKey",
|
|
433
|
+
"trackDisabledTriggerOnSafari",
|
|
434
|
+
"trackScroll",
|
|
435
|
+
"trackPointerlockChange",
|
|
436
|
+
"computePlacement"
|
|
437
|
+
],
|
|
438
|
+
entry: ["setGlobalId", "invokeOnOpen"],
|
|
439
|
+
on: {
|
|
440
|
+
POINTER_LEAVE: [
|
|
441
|
+
{
|
|
442
|
+
guard: "isVisible",
|
|
443
|
+
target: "closing"
|
|
444
|
+
},
|
|
445
|
+
{ target: "closed" }
|
|
446
|
+
],
|
|
447
|
+
BLUR: "closed",
|
|
448
|
+
ESCAPE: "closed",
|
|
449
|
+
SCROLL: "closed",
|
|
450
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
451
|
+
TOOLTIP_POINTER_LEAVE: {
|
|
452
|
+
guard: "isInteractive",
|
|
442
453
|
target: "closing"
|
|
443
454
|
},
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
TOOLTIP_POINTER_LEAVE: {
|
|
451
|
-
guard: "isInteractive",
|
|
452
|
-
target: "closing"
|
|
453
|
-
},
|
|
454
|
-
POINTER_DOWN: {
|
|
455
|
-
guard: "closeOnPointerDown",
|
|
456
|
-
target: "closed"
|
|
457
|
-
},
|
|
458
|
-
CLICK: "closed"
|
|
459
|
-
}
|
|
460
|
-
},
|
|
461
|
-
closing: {
|
|
462
|
-
tags: ["open"],
|
|
463
|
-
activities: ["trackStore", "computePlacement"],
|
|
464
|
-
after: {
|
|
465
|
-
CLOSE_DELAY: "closed"
|
|
455
|
+
POINTER_DOWN: {
|
|
456
|
+
guard: "closeOnPointerDown",
|
|
457
|
+
target: "closed"
|
|
458
|
+
},
|
|
459
|
+
CLICK: "closed"
|
|
460
|
+
}
|
|
466
461
|
},
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
462
|
+
closing: {
|
|
463
|
+
tags: ["open"],
|
|
464
|
+
activities: ["trackStore", "computePlacement"],
|
|
465
|
+
after: {
|
|
466
|
+
CLOSE_DELAY: "closed"
|
|
467
|
+
},
|
|
468
|
+
on: {
|
|
469
|
+
FORCE_CLOSE: "closed",
|
|
470
|
+
POINTER_ENTER: "open",
|
|
471
|
+
TOOLTIP_POINTER_ENTER: {
|
|
472
|
+
guard: "isInteractive",
|
|
473
|
+
target: "open"
|
|
474
|
+
}
|
|
473
475
|
}
|
|
474
476
|
}
|
|
475
477
|
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
activities: {
|
|
481
|
+
computePlacement(ctx2) {
|
|
482
|
+
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
483
|
+
let cleanup;
|
|
484
|
+
raf(() => {
|
|
485
|
+
cleanup = (0, import_popper2.getPlacement)(dom.getTriggerEl(ctx2), dom.getPositionerEl(ctx2), {
|
|
486
|
+
...ctx2.positioning,
|
|
487
|
+
onComplete(data) {
|
|
488
|
+
ctx2.currentPlacement = data.placement;
|
|
489
|
+
ctx2.isPlacementComplete = true;
|
|
490
|
+
},
|
|
491
|
+
onCleanup() {
|
|
492
|
+
ctx2.currentPlacement = void 0;
|
|
493
|
+
ctx2.isPlacementComplete = false;
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
return cleanup;
|
|
498
|
+
},
|
|
499
|
+
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
500
|
+
return addPointerlockChangeListener(dom.getDoc(ctx2), () => {
|
|
501
|
+
send("POINTER_LOCK_CHANGE");
|
|
502
|
+
});
|
|
503
|
+
},
|
|
504
|
+
trackScroll(ctx2, _evt, { send }) {
|
|
505
|
+
const trigger = dom.getTriggerEl(ctx2);
|
|
506
|
+
if (!trigger)
|
|
507
|
+
return;
|
|
508
|
+
const cleanups = getScrollParents(trigger).map((el) => {
|
|
509
|
+
const opts = { passive: true, capture: true };
|
|
510
|
+
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
511
|
+
});
|
|
512
|
+
return () => {
|
|
513
|
+
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
514
|
+
};
|
|
515
|
+
},
|
|
516
|
+
trackStore(ctx2, _evt, { send }) {
|
|
517
|
+
return (0, import_core2.subscribe)(store, () => {
|
|
518
|
+
if (store.id !== ctx2.id) {
|
|
519
|
+
send("FORCE_CLOSE");
|
|
492
520
|
}
|
|
493
521
|
});
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
498
|
-
return addPointerlockChangeListener(dom.getDoc(ctx2), () => {
|
|
499
|
-
send("POINTER_LOCK_CHANGE");
|
|
500
|
-
});
|
|
501
|
-
},
|
|
502
|
-
trackScroll(ctx2, _evt, { send }) {
|
|
503
|
-
const trigger = dom.getTriggerEl(ctx2);
|
|
504
|
-
if (!trigger)
|
|
505
|
-
return;
|
|
506
|
-
const cleanups = getScrollParents(trigger).map((el) => {
|
|
507
|
-
const opts = { passive: true, capture: true };
|
|
508
|
-
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
509
|
-
});
|
|
510
|
-
return () => {
|
|
511
|
-
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
512
|
-
};
|
|
513
|
-
},
|
|
514
|
-
trackStore(ctx2, _evt, { send }) {
|
|
515
|
-
return (0, import_core2.subscribe)(store, () => {
|
|
516
|
-
if (store.id !== ctx2.id) {
|
|
517
|
-
send("FORCE_CLOSE");
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
},
|
|
521
|
-
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
522
|
-
if (!isSafari())
|
|
523
|
-
return;
|
|
524
|
-
const doc = dom.getDoc(ctx2);
|
|
525
|
-
return addPointerEvent(doc, "pointermove", (event) => {
|
|
526
|
-
const selector = "[data-part=trigger][data-expanded]";
|
|
527
|
-
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
522
|
+
},
|
|
523
|
+
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
524
|
+
if (!isSafari())
|
|
528
525
|
return;
|
|
529
|
-
|
|
530
|
-
|
|
526
|
+
const doc = dom.getDoc(ctx2);
|
|
527
|
+
return addPointerEvent(doc, "pointermove", (event) => {
|
|
528
|
+
const selector = "[data-part=trigger][data-expanded]";
|
|
529
|
+
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
530
|
+
return;
|
|
531
|
+
send("POINTER_LEAVE");
|
|
532
|
+
});
|
|
533
|
+
},
|
|
534
|
+
trackEscapeKey(ctx2, _evt, { send }) {
|
|
535
|
+
if (!ctx2.closeOnEsc)
|
|
536
|
+
return;
|
|
537
|
+
const doc = dom.getDoc(ctx2);
|
|
538
|
+
return addDomEvent(doc, "keydown", (event) => {
|
|
539
|
+
if (event.key === "Escape") {
|
|
540
|
+
send("ESCAPE");
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
531
544
|
},
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
if (
|
|
538
|
-
|
|
545
|
+
actions: {
|
|
546
|
+
setGlobalId(ctx2) {
|
|
547
|
+
store.setId(ctx2.id);
|
|
548
|
+
},
|
|
549
|
+
clearGlobalId(ctx2) {
|
|
550
|
+
if (ctx2.id === store.id) {
|
|
551
|
+
store.setId(null);
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
invokeOnOpen(ctx2, evt) {
|
|
555
|
+
var _a;
|
|
556
|
+
const omit = ["TOOLTIP_POINTER_ENTER", "POINTER_ENTER"];
|
|
557
|
+
if (!omit.includes(evt.type)) {
|
|
558
|
+
(_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
invokeOnClose(ctx2, evt) {
|
|
562
|
+
var _a;
|
|
563
|
+
const omit = ["SETUP"];
|
|
564
|
+
if (!omit.includes(evt.type)) {
|
|
565
|
+
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
539
566
|
}
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
},
|
|
543
|
-
actions: {
|
|
544
|
-
setGlobalId(ctx2) {
|
|
545
|
-
store.setId(ctx2.id);
|
|
546
|
-
},
|
|
547
|
-
clearGlobalId(ctx2) {
|
|
548
|
-
if (ctx2.id === store.id) {
|
|
549
|
-
store.setId(null);
|
|
550
567
|
}
|
|
551
568
|
},
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
569
|
+
guards: {
|
|
570
|
+
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
571
|
+
noVisibleTooltip: () => store.id === null,
|
|
572
|
+
isVisible: (ctx2) => ctx2.id === store.id,
|
|
573
|
+
isInteractive: (ctx2) => ctx2.interactive
|
|
558
574
|
},
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (!omit.includes(evt.type)) {
|
|
563
|
-
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
564
|
-
}
|
|
575
|
+
delays: {
|
|
576
|
+
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
577
|
+
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
565
578
|
}
|
|
566
|
-
},
|
|
567
|
-
guards: {
|
|
568
|
-
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
569
|
-
noVisibleTooltip: () => store.id === null,
|
|
570
|
-
isVisible: (ctx2) => ctx2.id === store.id,
|
|
571
|
-
isInteractive: (ctx2) => ctx2.interactive
|
|
572
|
-
},
|
|
573
|
-
delays: {
|
|
574
|
-
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
575
|
-
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
576
579
|
}
|
|
577
|
-
|
|
580
|
+
);
|
|
578
581
|
}
|
|
579
582
|
// Annotate the CommonJS export names for ESM import in node:
|
|
580
583
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -338,216 +338,219 @@ function connect(state, send, normalize) {
|
|
|
338
338
|
import { createMachine, subscribe } from "@zag-js/core";
|
|
339
339
|
import { getPlacement } from "@zag-js/popper";
|
|
340
340
|
function machine(ctx) {
|
|
341
|
-
return createMachine(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
},
|
|
357
|
-
computed: {
|
|
358
|
-
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
359
|
-
},
|
|
360
|
-
on: {
|
|
361
|
-
OPEN: "open",
|
|
362
|
-
CLOSE: "closed"
|
|
363
|
-
},
|
|
364
|
-
states: {
|
|
365
|
-
unknown: {
|
|
366
|
-
on: {
|
|
367
|
-
SETUP: "closed"
|
|
341
|
+
return createMachine(
|
|
342
|
+
{
|
|
343
|
+
id: "tooltip",
|
|
344
|
+
initial: "unknown",
|
|
345
|
+
context: {
|
|
346
|
+
openDelay: 1e3,
|
|
347
|
+
closeDelay: 500,
|
|
348
|
+
closeOnPointerDown: true,
|
|
349
|
+
closeOnEsc: true,
|
|
350
|
+
interactive: true,
|
|
351
|
+
currentPlacement: void 0,
|
|
352
|
+
...ctx,
|
|
353
|
+
positioning: {
|
|
354
|
+
placement: "bottom",
|
|
355
|
+
...ctx.positioning
|
|
368
356
|
}
|
|
369
357
|
},
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
entry: ["clearGlobalId", "invokeOnClose"],
|
|
373
|
-
on: {
|
|
374
|
-
FOCUS: "open",
|
|
375
|
-
POINTER_ENTER: [
|
|
376
|
-
{
|
|
377
|
-
guard: "noVisibleTooltip",
|
|
378
|
-
target: "opening"
|
|
379
|
-
},
|
|
380
|
-
{ target: "open" }
|
|
381
|
-
]
|
|
382
|
-
}
|
|
358
|
+
computed: {
|
|
359
|
+
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
383
360
|
},
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
361
|
+
on: {
|
|
362
|
+
OPEN: "open",
|
|
363
|
+
CLOSE: "closed"
|
|
364
|
+
},
|
|
365
|
+
states: {
|
|
366
|
+
unknown: {
|
|
367
|
+
on: {
|
|
368
|
+
SETUP: "closed"
|
|
369
|
+
}
|
|
389
370
|
},
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
371
|
+
closed: {
|
|
372
|
+
tags: ["closed"],
|
|
373
|
+
entry: ["clearGlobalId", "invokeOnClose"],
|
|
374
|
+
on: {
|
|
375
|
+
FOCUS: "open",
|
|
376
|
+
POINTER_ENTER: [
|
|
377
|
+
{
|
|
378
|
+
guard: "noVisibleTooltip",
|
|
379
|
+
target: "opening"
|
|
380
|
+
},
|
|
381
|
+
{ target: "open" }
|
|
382
|
+
]
|
|
398
383
|
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
384
|
+
},
|
|
385
|
+
opening: {
|
|
386
|
+
tags: ["closed"],
|
|
387
|
+
activities: ["trackScroll", "trackPointerlockChange"],
|
|
388
|
+
after: {
|
|
389
|
+
OPEN_DELAY: "open"
|
|
390
|
+
},
|
|
391
|
+
on: {
|
|
392
|
+
POINTER_LEAVE: "closed",
|
|
393
|
+
BLUR: "closed",
|
|
394
|
+
SCROLL: "closed",
|
|
395
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
396
|
+
POINTER_DOWN: {
|
|
397
|
+
guard: "closeOnPointerDown",
|
|
398
|
+
target: "closed"
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
open: {
|
|
403
|
+
tags: ["open"],
|
|
404
|
+
activities: [
|
|
405
|
+
"trackEscapeKey",
|
|
406
|
+
"trackDisabledTriggerOnSafari",
|
|
407
|
+
"trackScroll",
|
|
408
|
+
"trackPointerlockChange",
|
|
409
|
+
"computePlacement"
|
|
410
|
+
],
|
|
411
|
+
entry: ["setGlobalId", "invokeOnOpen"],
|
|
412
|
+
on: {
|
|
413
|
+
POINTER_LEAVE: [
|
|
414
|
+
{
|
|
415
|
+
guard: "isVisible",
|
|
416
|
+
target: "closing"
|
|
417
|
+
},
|
|
418
|
+
{ target: "closed" }
|
|
419
|
+
],
|
|
420
|
+
BLUR: "closed",
|
|
421
|
+
ESCAPE: "closed",
|
|
422
|
+
SCROLL: "closed",
|
|
423
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
424
|
+
TOOLTIP_POINTER_LEAVE: {
|
|
425
|
+
guard: "isInteractive",
|
|
415
426
|
target: "closing"
|
|
416
427
|
},
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
TOOLTIP_POINTER_LEAVE: {
|
|
424
|
-
guard: "isInteractive",
|
|
425
|
-
target: "closing"
|
|
426
|
-
},
|
|
427
|
-
POINTER_DOWN: {
|
|
428
|
-
guard: "closeOnPointerDown",
|
|
429
|
-
target: "closed"
|
|
430
|
-
},
|
|
431
|
-
CLICK: "closed"
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
closing: {
|
|
435
|
-
tags: ["open"],
|
|
436
|
-
activities: ["trackStore", "computePlacement"],
|
|
437
|
-
after: {
|
|
438
|
-
CLOSE_DELAY: "closed"
|
|
428
|
+
POINTER_DOWN: {
|
|
429
|
+
guard: "closeOnPointerDown",
|
|
430
|
+
target: "closed"
|
|
431
|
+
},
|
|
432
|
+
CLICK: "closed"
|
|
433
|
+
}
|
|
439
434
|
},
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
435
|
+
closing: {
|
|
436
|
+
tags: ["open"],
|
|
437
|
+
activities: ["trackStore", "computePlacement"],
|
|
438
|
+
after: {
|
|
439
|
+
CLOSE_DELAY: "closed"
|
|
440
|
+
},
|
|
441
|
+
on: {
|
|
442
|
+
FORCE_CLOSE: "closed",
|
|
443
|
+
POINTER_ENTER: "open",
|
|
444
|
+
TOOLTIP_POINTER_ENTER: {
|
|
445
|
+
guard: "isInteractive",
|
|
446
|
+
target: "open"
|
|
447
|
+
}
|
|
446
448
|
}
|
|
447
449
|
}
|
|
448
450
|
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
activities: {
|
|
454
|
+
computePlacement(ctx2) {
|
|
455
|
+
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
456
|
+
let cleanup;
|
|
457
|
+
raf(() => {
|
|
458
|
+
cleanup = getPlacement(dom.getTriggerEl(ctx2), dom.getPositionerEl(ctx2), {
|
|
459
|
+
...ctx2.positioning,
|
|
460
|
+
onComplete(data) {
|
|
461
|
+
ctx2.currentPlacement = data.placement;
|
|
462
|
+
ctx2.isPlacementComplete = true;
|
|
463
|
+
},
|
|
464
|
+
onCleanup() {
|
|
465
|
+
ctx2.currentPlacement = void 0;
|
|
466
|
+
ctx2.isPlacementComplete = false;
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
return cleanup;
|
|
471
|
+
},
|
|
472
|
+
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
473
|
+
return addPointerlockChangeListener(dom.getDoc(ctx2), () => {
|
|
474
|
+
send("POINTER_LOCK_CHANGE");
|
|
475
|
+
});
|
|
476
|
+
},
|
|
477
|
+
trackScroll(ctx2, _evt, { send }) {
|
|
478
|
+
const trigger = dom.getTriggerEl(ctx2);
|
|
479
|
+
if (!trigger)
|
|
480
|
+
return;
|
|
481
|
+
const cleanups = getScrollParents(trigger).map((el) => {
|
|
482
|
+
const opts = { passive: true, capture: true };
|
|
483
|
+
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
484
|
+
});
|
|
485
|
+
return () => {
|
|
486
|
+
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
487
|
+
};
|
|
488
|
+
},
|
|
489
|
+
trackStore(ctx2, _evt, { send }) {
|
|
490
|
+
return subscribe(store, () => {
|
|
491
|
+
if (store.id !== ctx2.id) {
|
|
492
|
+
send("FORCE_CLOSE");
|
|
465
493
|
}
|
|
466
494
|
});
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
471
|
-
return addPointerlockChangeListener(dom.getDoc(ctx2), () => {
|
|
472
|
-
send("POINTER_LOCK_CHANGE");
|
|
473
|
-
});
|
|
474
|
-
},
|
|
475
|
-
trackScroll(ctx2, _evt, { send }) {
|
|
476
|
-
const trigger = dom.getTriggerEl(ctx2);
|
|
477
|
-
if (!trigger)
|
|
478
|
-
return;
|
|
479
|
-
const cleanups = getScrollParents(trigger).map((el) => {
|
|
480
|
-
const opts = { passive: true, capture: true };
|
|
481
|
-
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
482
|
-
});
|
|
483
|
-
return () => {
|
|
484
|
-
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
485
|
-
};
|
|
486
|
-
},
|
|
487
|
-
trackStore(ctx2, _evt, { send }) {
|
|
488
|
-
return subscribe(store, () => {
|
|
489
|
-
if (store.id !== ctx2.id) {
|
|
490
|
-
send("FORCE_CLOSE");
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
},
|
|
494
|
-
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
495
|
-
if (!isSafari())
|
|
496
|
-
return;
|
|
497
|
-
const doc = dom.getDoc(ctx2);
|
|
498
|
-
return addPointerEvent(doc, "pointermove", (event) => {
|
|
499
|
-
const selector = "[data-part=trigger][data-expanded]";
|
|
500
|
-
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
495
|
+
},
|
|
496
|
+
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
497
|
+
if (!isSafari())
|
|
501
498
|
return;
|
|
502
|
-
|
|
503
|
-
|
|
499
|
+
const doc = dom.getDoc(ctx2);
|
|
500
|
+
return addPointerEvent(doc, "pointermove", (event) => {
|
|
501
|
+
const selector = "[data-part=trigger][data-expanded]";
|
|
502
|
+
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
503
|
+
return;
|
|
504
|
+
send("POINTER_LEAVE");
|
|
505
|
+
});
|
|
506
|
+
},
|
|
507
|
+
trackEscapeKey(ctx2, _evt, { send }) {
|
|
508
|
+
if (!ctx2.closeOnEsc)
|
|
509
|
+
return;
|
|
510
|
+
const doc = dom.getDoc(ctx2);
|
|
511
|
+
return addDomEvent(doc, "keydown", (event) => {
|
|
512
|
+
if (event.key === "Escape") {
|
|
513
|
+
send("ESCAPE");
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
504
517
|
},
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
if (
|
|
511
|
-
|
|
518
|
+
actions: {
|
|
519
|
+
setGlobalId(ctx2) {
|
|
520
|
+
store.setId(ctx2.id);
|
|
521
|
+
},
|
|
522
|
+
clearGlobalId(ctx2) {
|
|
523
|
+
if (ctx2.id === store.id) {
|
|
524
|
+
store.setId(null);
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
invokeOnOpen(ctx2, evt) {
|
|
528
|
+
var _a;
|
|
529
|
+
const omit = ["TOOLTIP_POINTER_ENTER", "POINTER_ENTER"];
|
|
530
|
+
if (!omit.includes(evt.type)) {
|
|
531
|
+
(_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
invokeOnClose(ctx2, evt) {
|
|
535
|
+
var _a;
|
|
536
|
+
const omit = ["SETUP"];
|
|
537
|
+
if (!omit.includes(evt.type)) {
|
|
538
|
+
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
512
539
|
}
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
},
|
|
516
|
-
actions: {
|
|
517
|
-
setGlobalId(ctx2) {
|
|
518
|
-
store.setId(ctx2.id);
|
|
519
|
-
},
|
|
520
|
-
clearGlobalId(ctx2) {
|
|
521
|
-
if (ctx2.id === store.id) {
|
|
522
|
-
store.setId(null);
|
|
523
540
|
}
|
|
524
541
|
},
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
542
|
+
guards: {
|
|
543
|
+
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
544
|
+
noVisibleTooltip: () => store.id === null,
|
|
545
|
+
isVisible: (ctx2) => ctx2.id === store.id,
|
|
546
|
+
isInteractive: (ctx2) => ctx2.interactive
|
|
531
547
|
},
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if (!omit.includes(evt.type)) {
|
|
536
|
-
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
537
|
-
}
|
|
548
|
+
delays: {
|
|
549
|
+
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
550
|
+
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
538
551
|
}
|
|
539
|
-
},
|
|
540
|
-
guards: {
|
|
541
|
-
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
542
|
-
noVisibleTooltip: () => store.id === null,
|
|
543
|
-
isVisible: (ctx2) => ctx2.id === store.id,
|
|
544
|
-
isInteractive: (ctx2) => ctx2.interactive
|
|
545
|
-
},
|
|
546
|
-
delays: {
|
|
547
|
-
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
548
|
-
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
549
552
|
}
|
|
550
|
-
|
|
553
|
+
);
|
|
551
554
|
}
|
|
552
555
|
export {
|
|
553
556
|
connect,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tooltip",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Core logic for the tooltip widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.1.
|
|
33
|
-
"@zag-js/popper": "0.1.
|
|
34
|
-
"@zag-js/types": "0.2.
|
|
32
|
+
"@zag-js/core": "0.1.10",
|
|
33
|
+
"@zag-js/popper": "0.1.11",
|
|
34
|
+
"@zag-js/types": "0.2.5"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@zag-js/dom-utils": "0.1.
|
|
38
|
-
"@zag-js/utils": "0.1.
|
|
37
|
+
"@zag-js/dom-utils": "0.1.11",
|
|
38
|
+
"@zag-js/utils": "0.1.4"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build-fast": "tsup src/index.ts --format=esm,cjs",
|