@salilvnair/dui 1.0.12 → 1.0.13
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/README.md +76 -33
- package/dist/index.js +3726 -3713
- package/dist/index.js.map +1 -1
- package/dist/lib/components/input/select-position.d.ts +54 -0
- package/package.json +4 -2
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a select's menu goes, and how tall it is allowed to be.
|
|
3
|
+
*
|
|
4
|
+
* ── Why this is its own module ──
|
|
5
|
+
*
|
|
6
|
+
* It used to live inline in `SelectInputView`, with a copy of the same
|
|
7
|
+
* arithmetic in the test beside it and a comment promising the two were "kept
|
|
8
|
+
* in step by construction". They were, for a while. A test that owns a second
|
|
9
|
+
* copy of the thing it is testing cannot fail when the first copy drifts,
|
|
10
|
+
* which is the one job it had — so there is now one function, and the test
|
|
11
|
+
* imports it.
|
|
12
|
+
*
|
|
13
|
+
* ── The rule ──
|
|
14
|
+
*
|
|
15
|
+
* The decision has to use the height the menu will ACTUALLY be, not the height
|
|
16
|
+
* of its contents. `scrollHeight` for a few hundred options is many thousands
|
|
17
|
+
* of pixels; comparing that against the space on either side made every long
|
|
18
|
+
* list decide nothing fitted, fall through to opening downward, and run off
|
|
19
|
+
* the bottom of the window. The longer the list, the more certain it was to do
|
|
20
|
+
* the wrong thing.
|
|
21
|
+
*
|
|
22
|
+
* So: cap the height first, then choose the side with room, then clamp to the
|
|
23
|
+
* room that side actually has. The menu scrolls internally rather than past
|
|
24
|
+
* the edge of the window.
|
|
25
|
+
*/
|
|
26
|
+
/** Nothing taller than this, however long the list. */
|
|
27
|
+
export declare const MAX_MENU_H = 380;
|
|
28
|
+
/**
|
|
29
|
+
* Never collapse to a sliver.
|
|
30
|
+
*
|
|
31
|
+
* A trigger a few pixels from an edge has almost no room on that side, and a
|
|
32
|
+
* 12px menu is unusable — better to overlap the trigger slightly and stay
|
|
33
|
+
* readable. `placeSelectMenu` honours that by keeping the height and sliding
|
|
34
|
+
* the menu back inside the window, rather than by letting it hang over the
|
|
35
|
+
* edge where the overlapped part cannot be reached at all.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MIN_MENU_H = 120;
|
|
38
|
+
export interface MenuPlacement {
|
|
39
|
+
side: 'above' | 'below';
|
|
40
|
+
/** Viewport coordinate for the menu's top edge. */
|
|
41
|
+
top: number;
|
|
42
|
+
/** What the menu may grow to. It scrolls beyond this. */
|
|
43
|
+
maxHeight: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Place the menu for a trigger at `rect` in a window `viewportHeight` tall.
|
|
47
|
+
*
|
|
48
|
+
* `contentHeight` is the menu's `scrollHeight` — what it would be if nothing
|
|
49
|
+
* constrained it. It informs the choice of side and never the final height.
|
|
50
|
+
*/
|
|
51
|
+
export declare function placeSelectMenu(rect: {
|
|
52
|
+
top: number;
|
|
53
|
+
bottom: number;
|
|
54
|
+
}, contentHeight: number, viewportHeight: number): MenuPlacement;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salilvnair/dui",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Daakia UI component library
|
|
3
|
+
"version": "1.0.13",
|
|
4
|
+
"description": "Daakia UI component library \u2014 shared across ck8t and daakia",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Salil V Nair",
|
|
@@ -75,6 +75,8 @@
|
|
|
75
75
|
"sheets": "node scripts/screenshots/sheets.mjs",
|
|
76
76
|
"catalog": "node scripts/screenshots/readme-catalog.mjs",
|
|
77
77
|
"catalog:check": "node scripts/screenshots/readme-catalog.mjs --check",
|
|
78
|
+
"coverage": "node scripts/showcase/coverage.mjs",
|
|
79
|
+
"coverage:check": "node scripts/showcase/coverage.mjs --check",
|
|
78
80
|
"demo-video:record": "node scripts/demo-video/record.js",
|
|
79
81
|
"demo-video:compose": "node scripts/demo-video/compose.js",
|
|
80
82
|
"demo-video:refine": "node scripts/demo-video/refine.js",
|