@tristan2828/ui-foundation 4.136.0 → 4.136.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.
|
@@ -10,7 +10,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
// Placed against the field's element like the floating toolbar, not in a
|
|
11
11
|
// portal (rich-text-floating-toolbar.tsx says why): under the caret, or
|
|
12
12
|
// over it when there's more room there, and never taller than what is
|
|
13
|
-
// visible on its side (above a phone's keyboard, review F11).
|
|
13
|
+
// visible on its side (above a phone's keyboard, review F11). Visible
|
|
14
|
+
// means inside whatever clips the field too: a card's `overflow-hidden`
|
|
15
|
+
// cut a menu opened on a note's last line down to its first item.
|
|
14
16
|
import { useLayoutEffect, useState } from 'react';
|
|
15
17
|
import { cn } from 'cn';
|
|
16
18
|
import { slashOptionId } from './rich-text-slash.js';
|
|
@@ -21,15 +23,24 @@ const TALLEST = 512;
|
|
|
21
23
|
// Below the caret while at least this much of it fits there.
|
|
22
24
|
const ENOUGH = 170;
|
|
23
25
|
// What is visible of the window: above a phone's keyboard
|
|
24
|
-
// (`visualViewport`),
|
|
25
|
-
// (rich-text-keyboard-bar.tsx) when the field has one (review F11)
|
|
26
|
+
// (`visualViewport`), above the bar pinned to it
|
|
27
|
+
// (rich-text-keyboard-bar.tsx) when the field has one (review F11), and
|
|
28
|
+
// inside every element around the field that clips what overflows it (a
|
|
29
|
+
// card, a dialog's scrolling body).
|
|
26
30
|
function visibleArea(field) {
|
|
27
31
|
const viewport = window.visualViewport;
|
|
28
|
-
|
|
32
|
+
let top = viewport?.offsetTop ?? 0;
|
|
29
33
|
let bottom = top + (viewport?.height ?? window.innerHeight);
|
|
30
34
|
const bar = field.querySelector('[data-slot="rich-text-keyboard-bar"] [role="toolbar"]');
|
|
31
35
|
if (bar)
|
|
32
36
|
bottom = Math.min(bottom, bar.getBoundingClientRect().top);
|
|
37
|
+
for (let element = field; element && element !== document.body; element = element.parentElement) {
|
|
38
|
+
if (getComputedStyle(element).overflowY === 'visible')
|
|
39
|
+
continue;
|
|
40
|
+
const box = element.getBoundingClientRect();
|
|
41
|
+
top = Math.max(top, box.top);
|
|
42
|
+
bottom = Math.min(bottom, box.bottom);
|
|
43
|
+
}
|
|
33
44
|
return { top, bottom };
|
|
34
45
|
}
|
|
35
46
|
// Under the caret, or over it; on a touch screen never taller than the
|
|
@@ -42,14 +53,15 @@ function place(view, at, field, menu) {
|
|
|
42
53
|
const natural = Math.min(menu.scrollHeight, TALLEST);
|
|
43
54
|
const roomBelow = area.bottom - caret.bottom - GAP * 2;
|
|
44
55
|
const roomAbove = caret.top - area.top - GAP * 2;
|
|
45
|
-
// A laptop's
|
|
46
|
-
// A touch screen's: below while
|
|
47
|
-
// more room
|
|
56
|
+
// A laptop's: below when it all fits there, else above when it fits
|
|
57
|
+
// there, else wherever there's more room. A touch screen's: below while
|
|
58
|
+
// a few items fit, else wherever there's more room. Either way capped to
|
|
59
|
+
// the room on its side, so it scrolls rather than being cut off.
|
|
48
60
|
const touch = window.matchMedia('(pointer: coarse)').matches;
|
|
49
61
|
const below = touch
|
|
50
62
|
? roomBelow >= Math.min(natural, ENOUGH) || roomBelow >= roomAbove
|
|
51
|
-
:
|
|
52
|
-
const maxHeight =
|
|
63
|
+
: natural <= roomBelow || (natural > roomAbove && roomBelow >= roomAbove);
|
|
64
|
+
const maxHeight = Math.max(80, Math.min(TALLEST, below ? roomBelow : roomAbove));
|
|
53
65
|
const height = Math.min(natural, maxHeight);
|
|
54
66
|
const top = below ? caret.bottom + GAP : caret.top - GAP - height;
|
|
55
67
|
const left = Math.max(0, Math.min(caret.left - box.left, box.width - width));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.136.
|
|
3
|
+
"version": "4.136.1",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|