@jungherz-de/notionkit-elements 1.9.0 → 1.10.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.
@@ -8,7 +8,7 @@ import { NkElement } from '../../base.js';
8
8
  // row; clicking outside or pressing Escape closes it.
9
9
  const menuSheet = new CSSStyleSheet();
10
10
  menuSheet.replaceSync(`
11
- .nk-ws-anchor { position: relative; }
11
+ .nk-ws-anchor { position: relative; flex: 1 1 auto; min-width: 0; }
12
12
  .nk-ws-menu { display: none; position: absolute; left: 8px; top: calc(100% - 2px); z-index: 50; }
13
13
  :host([open]) .nk-ws-menu { display: block; }
14
14
  `);
package/src/index.js CHANGED
@@ -90,6 +90,8 @@ export { NkCopyField } from './components/forms/nk-copy-field.js';
90
90
  export { NkImagePicker } from './components/forms/nk-image-picker.js';
91
91
  export { NkCalendar } from './components/forms/nk-calendar.js';
92
92
  export { NkPeek } from './components/overlays/nk-peek.js';
93
+ export { NkDialog } from './components/overlays/nk-dialog.js';
94
+ export { NkTooltip } from './components/overlays/nk-tooltip.js';
93
95
 
94
96
  // Wave 4 – overlays
95
97
  export { NkModal } from './components/overlays/nk-modal.js';
@@ -11,6 +11,21 @@ export function boxOf(el) {
11
11
  return el.getBoundingClientRect();
12
12
  }
13
13
 
14
+ /**
15
+ * Puts `host` 6px below `target` – an element or a rect ({ left, top, right,
16
+ * bottom }, a DOMRect) – centred on it: above with side="top", or where the
17
+ * window ends below; kept 8px inside the window. For <nk-tooltip>.
18
+ */
19
+ export function placeNear(host, target, side = 'bottom', gap = 6) {
20
+ const r = target instanceof Element ? boxOf(target) : target;
21
+ const { width: w, height: h } = host.getBoundingClientRect();
22
+ const below = r.bottom + gap, above = r.top - gap - h;
23
+ const top = side === 'top' ? (above < 8 ? below : above) : (below + h > innerHeight - 8 ? above : below);
24
+ host.style.top = `${Math.round(top)}px`;
25
+ host.style.left = `${Math.round(Math.min(Math.max(8, (r.left + r.right) / 2 - w / 2), innerWidth - 8 - w))}px`;
26
+ host.style.right = '';
27
+ }
28
+
14
29
  /** Puts `host` 6px under `anchor`, right edges aligned – left edges with align="start". */
15
30
  export function placeUnder(host, anchor, align) {
16
31
  const r = boxOf(anchor);