@jungherz-de/notionkit-elements 1.20.0 → 1.20.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/CHANGELOG.md +29 -0
- package/README.md +3 -3
- package/SKILL.md +13 -13
- package/dist/components/nk-tooltip.js +61 -5
- package/dist/notionkit-elements.esm.js +61 -5
- package/dist/notionkit-elements.esm.min.js +1 -1
- package/dist/notionkit-elements.esm.min.js.map +1 -1
- package/dist/notionkit-elements.js +61 -5
- package/dist/notionkit-elements.min.js +1 -1
- package/package.json +1 -1
- package/src/components/overlays/nk-tooltip.js +61 -5
|
@@ -5639,6 +5639,17 @@ var NotionKitElements = (function (exports) {
|
|
|
5639
5639
|
// [data-tooltip], a press or Escape. A line break in the text is kept.
|
|
5640
5640
|
// While it shows, the target's aria-describedby names it (in the same
|
|
5641
5641
|
// document or shadow root).
|
|
5642
|
+
//
|
|
5643
|
+
// Following the pointer and the focus inside a shadow root (1.20.1):
|
|
5644
|
+
// pointerover, focusin and focusout carry a relatedTarget, and when target
|
|
5645
|
+
// and relatedTarget share a shadow tree the DOM standard ends the event path
|
|
5646
|
+
// at its host – the document never hears of a move from one [data-tooltip]
|
|
5647
|
+
// to the next in the same root. So the pointer is also read from
|
|
5648
|
+
// pointermove, which has no relatedTarget, and acted on only when the
|
|
5649
|
+
// element under it changes; and a key that moved the focus – Tab, the arrow
|
|
5650
|
+
// keys of a group – is caught on keyup, comparing the focused element with
|
|
5651
|
+
// the one before the key went down. A move by script alone inside one
|
|
5652
|
+
// shadow root stays unseen.
|
|
5642
5653
|
const hostSheet = new CSSStyleSheet();
|
|
5643
5654
|
hostSheet.replaceSync(`:host { display: block; position: fixed; top: 0; left: 0; z-index: 130; pointer-events: none; }`);
|
|
5644
5655
|
let count = 0;
|
|
@@ -5716,14 +5727,50 @@ var NotionKitElements = (function (exports) {
|
|
|
5716
5727
|
this.show(el, own ? null : el.getAttribute('data-tooltip'), own ? this.getAttribute('shortcut') : el.getAttribute('data-tooltip-key'));
|
|
5717
5728
|
}
|
|
5718
5729
|
|
|
5730
|
+
/**
|
|
5731
|
+
* The pointer is over `el` now (null: no [data-tooltip]). pointerover acts
|
|
5732
|
+
* on every boundary it crosses, as it always has; pointermove – the only
|
|
5733
|
+
* one that reaches the document from inside a shadow root – only when the
|
|
5734
|
+
* element under the pointer changed, so a hand resting on the page leaves
|
|
5735
|
+
* a tooltip the keyboard or show(rect) opened alone.
|
|
5736
|
+
*/
|
|
5737
|
+
_pointer(e, move) {
|
|
5738
|
+
const el = e.pointerType === 'touch' ? null : this._targetOf(e);
|
|
5739
|
+
if (move && el === this._hover) return;
|
|
5740
|
+
this._hover = el;
|
|
5741
|
+
if (el === this._target) return;
|
|
5742
|
+
this.hide();
|
|
5743
|
+
if (!el) return;
|
|
5744
|
+
this._target = el;
|
|
5745
|
+
this._timer = setTimeout(() => this._showFor(el), this._delay);
|
|
5746
|
+
}
|
|
5747
|
+
|
|
5719
5748
|
setupEvents() {
|
|
5720
|
-
this._onOver = (e) =>
|
|
5721
|
-
|
|
5722
|
-
|
|
5749
|
+
this._onOver = (e) => this._pointer(e, false);
|
|
5750
|
+
this._onMove = (e) => this._pointer(e, true);
|
|
5751
|
+
// The pointer left the window (no relatedTarget): a tooltip – shown or
|
|
5752
|
+
// still waiting – for what it was on goes with it. One the keyboard or
|
|
5753
|
+
// show(rect) opened is not the pointer's and stays.
|
|
5754
|
+
this._onOut = (e) => {
|
|
5755
|
+
if (e.relatedTarget || e.pointerType === 'touch') return;
|
|
5756
|
+
if (this._target && this._target === this._hover) this.hide();
|
|
5757
|
+
this._hover = null;
|
|
5758
|
+
};
|
|
5759
|
+
// Capture, before an element's own keydown moves the focus (a roving tab
|
|
5760
|
+
// stop does); not for a held key's repeats, so keyup compares with where
|
|
5761
|
+
// the focus was before the key went down.
|
|
5762
|
+
this._onKeyDown = (e) => { if (!e.repeat) this._focusBefore = deepActiveElement(); };
|
|
5763
|
+
this._onKeyUp = (e) => {
|
|
5764
|
+
const active = deepActiveElement();
|
|
5765
|
+
if (active === this._focusBefore) return;
|
|
5766
|
+
this._focusBefore = active;
|
|
5767
|
+
// keyup goes to the focused element, so its path is the focus's path.
|
|
5768
|
+
const el = this._targetOf(e);
|
|
5769
|
+
if (el && el === this._target) return; // focusin got there first
|
|
5723
5770
|
this.hide();
|
|
5724
|
-
if (!el) return;
|
|
5771
|
+
if (!el || !active?.matches(':focus-visible')) return;
|
|
5725
5772
|
this._target = el;
|
|
5726
|
-
this.
|
|
5773
|
+
this._showFor(el);
|
|
5727
5774
|
};
|
|
5728
5775
|
this._onFocus = (e) => {
|
|
5729
5776
|
const el = this._targetOf(e);
|
|
@@ -5735,7 +5782,11 @@ var NotionKitElements = (function (exports) {
|
|
|
5735
5782
|
this._onHide = () => this.hide();
|
|
5736
5783
|
this._onKey = (e) => { if (e.key === 'Escape' && this.open) this.hide(); };
|
|
5737
5784
|
document.addEventListener('pointerover', this._onOver);
|
|
5785
|
+
document.addEventListener('pointermove', this._onMove, { capture: true, passive: true });
|
|
5786
|
+
document.addEventListener('pointerout', this._onOut);
|
|
5738
5787
|
document.addEventListener('focusin', this._onFocus);
|
|
5788
|
+
document.addEventListener('keydown', this._onKeyDown, true);
|
|
5789
|
+
document.addEventListener('keyup', this._onKeyUp, true);
|
|
5739
5790
|
document.addEventListener('focusout', this._onHide);
|
|
5740
5791
|
document.addEventListener('pointerdown', this._onHide, true);
|
|
5741
5792
|
document.addEventListener('scroll', this._onHide, true);
|
|
@@ -5746,13 +5797,18 @@ var NotionKitElements = (function (exports) {
|
|
|
5746
5797
|
|
|
5747
5798
|
teardownEvents() {
|
|
5748
5799
|
document.removeEventListener('pointerover', this._onOver);
|
|
5800
|
+
document.removeEventListener('pointermove', this._onMove, { capture: true });
|
|
5801
|
+
document.removeEventListener('pointerout', this._onOut);
|
|
5749
5802
|
document.removeEventListener('focusin', this._onFocus);
|
|
5803
|
+
document.removeEventListener('keydown', this._onKeyDown, true);
|
|
5804
|
+
document.removeEventListener('keyup', this._onKeyUp, true);
|
|
5750
5805
|
document.removeEventListener('focusout', this._onHide);
|
|
5751
5806
|
document.removeEventListener('pointerdown', this._onHide, true);
|
|
5752
5807
|
document.removeEventListener('scroll', this._onHide, true);
|
|
5753
5808
|
document.removeEventListener('wheel', this._onHide, { capture: true });
|
|
5754
5809
|
document.removeEventListener('keydown', this._onKey);
|
|
5755
5810
|
this.hide();
|
|
5811
|
+
this._hover = this._focusBefore = null;
|
|
5756
5812
|
}
|
|
5757
5813
|
|
|
5758
5814
|
onAttributeChanged(name) { if (name === 'shortcut' && !this._text.data) this._fill(null); if (name === 'for') this.hide(); }
|