@n-uf/placement 26.11.53 → 26.11.55
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 +149 -1
- package/README.md +38 -58
- package/dist/{chunk-VLTYJHUA.js → chunk-2UVUFEBP.js} +4 -8
- package/dist/{chunk-VLTYJHUA.js.map → chunk-2UVUFEBP.js.map} +1 -1
- package/dist/{geometry-Bf37LbCT.d.ts → geometry-L5gCoiZV.d.ts} +2 -8
- package/dist/index.d.ts +64 -42
- package/dist/index.js +6 -66
- package/dist/index.js.map +1 -1
- package/dist/popup.d.ts +49 -0
- package/dist/popup.js +58 -0
- package/dist/popup.js.map +1 -0
- package/dist/stack.d.ts +611 -225
- package/dist/stack.js +843 -28
- package/dist/stack.js.map +1 -1
- package/dist/tiling.d.ts +239 -18
- package/dist/tiling.js +372 -19
- package/dist/tiling.js.map +1 -1
- package/package.json +9 -36
- package/dist/chunk-2GGJ4GVR.js +0 -9
- package/dist/chunk-2GGJ4GVR.js.map +0 -1
- package/dist/chunk-3ZICYLWL.js +0 -791
- package/dist/chunk-3ZICYLWL.js.map +0 -1
- package/dist/chunk-AE3BWTAE.js +0 -838
- package/dist/chunk-AE3BWTAE.js.map +0 -1
- package/dist/chunk-JVAR67OL.js +0 -172
- package/dist/chunk-JVAR67OL.js.map +0 -1
- package/dist/chunk-NF7RYK3U.js +0 -429
- package/dist/chunk-NF7RYK3U.js.map +0 -1
- package/dist/chunk-R3AAANRY.js +0 -220
- package/dist/chunk-R3AAANRY.js.map +0 -1
- package/dist/chunk-TWI644JK.js +0 -221
- package/dist/chunk-TWI644JK.js.map +0 -1
- package/dist/chunk-ZTH5FCUO.js +0 -4190
- package/dist/chunk-ZTH5FCUO.js.map +0 -1
- package/dist/constructions-Cbz7uEAZ.d.ts +0 -251
- package/dist/desk.d.ts +0 -51
- package/dist/desk.js +0 -111
- package/dist/desk.js.map +0 -1
- package/dist/dock.d.ts +0 -25
- package/dist/dock.js +0 -397
- package/dist/dock.js.map +0 -1
- package/dist/float-fit-DCYxRMru.d.ts +0 -37
- package/dist/lanes-DIwUqchd.d.ts +0 -1321
- package/dist/model-X7eUaKlA.d.ts +0 -337
- package/dist/panels.d.ts +0 -60
- package/dist/panels.js +0 -99
- package/dist/panels.js.map +0 -1
- package/dist/regions-Db_RyT4P.d.ts +0 -48
- package/dist/scene-cases.d.ts +0 -888
- package/dist/scene-cases.js +0 -3149
- package/dist/scene-cases.js.map +0 -1
- package/dist/scene.d.ts +0 -290
- package/dist/scene.js +0 -128
- package/dist/scene.js.map +0 -1
- package/dist/target-BBOCeez2.d.ts +0 -69
- package/dist/targets-C9ZVhmCl.d.ts +0 -621
- package/dist/targets.d.ts +0 -212
- package/dist/targets.js +0 -447
- package/dist/targets.js.map +0 -1
- package/dist/toolbar.d.ts +0 -167
- package/dist/toolbar.js +0 -55
- package/dist/toolbar.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/target.ts"],"sourcesContent":["import type { Rect } from \"./geometry\";\n\n/**\n * A drop target in the shape @n-uf/motion/drag takes: an id, a priority (1 most precise: a rail or a tab strip;\n * 2 a slot; 3 a broad area such as floating anywhere), the zone the pointer hits, and optionally where the item\n * lands, a label and whether it lands freely (no room is made for it). `hits`, when given, is the whole zone as several\n * rects (a zone that isn't one rect), `hit` the largest of them: the pointer is in the zone when it is in any of them.\n * `arm: \"dwell\"` marks a spring-loaded target (the drag intent arms it once the pointer dwells in it), `armedHit` its\n * zone once armed.\n */\nexport interface Target {\n readonly id: string;\n readonly priority: 1 | 2 | 3;\n readonly hit: Rect;\n readonly hits?: readonly Rect[];\n /** Spring-loaded: no target until the pointer dwells in it. */\n readonly arm?: \"dwell\";\n /** Its zone once armed (the strip grown by its magnet). */\n readonly armedHit?: Rect;\n readonly slot?: Rect;\n readonly label?: string;\n readonly free?: boolean;\n /**\n * A refusal, not a target: it takes part in the pick under the pointer, ranked after every target of priority 1 and 2\n * and before priority 3 (`REFUSAL_RANK`, whatever its `priority`), but nothing lands on it (`refusalTargets`).\n */\n readonly refuse?: true;\n /**\n * The drawn space the zone belongs to (the window's stage): the zone, and a drag intent's band and gap grace about\n * it, hold only points strictly inside it. The window's boundary belongs only to the targets drawn against it: the\n * docking model gives `bounds` to every refusal and to the float (whole-plane), never to a gap or a slot, so a pointer clamped\n * onto the window's edge picks a gap that reaches it, else nothing. That relies on the host clamping exactly onto the\n * stage's edge (`x + width`, `y + height`): a host that clamps to `width - 0.5` still picks inside the window.\n */\n readonly bounds?: Rect;\n /**\n * Its room opens as it shows: the docking model sets it on a target whose slot overlaps an item its drop moves (a rail pushing\n * a column, a new-column line, a bar's strip over the columns), and on a rail drop strip's targets, whose room opens\n * once armed. The drag intent then shows it and makes its room in one frame. Until it shows, a release still lands on\n * it.\n */\n readonly opensRoom?: true;\n /**\n * With `opensRoom`, how long it holds before it shows with its room, ms, in place of the drag intent's `roomAfter`. The\n * docking model sets it to `EDGE_ROOM_HOLD` on a rail target or a new-column line against the window's left or right edge.\n */\n readonly roomHold?: number;\n /**\n * With `opensRoom`, the zone it holds once its room is open: while the target shows with its room open, a drag intent\n * holds it wherever the pointer is in this rect. The docking model sets it to the smallest rect holding `hit` and the slot (the\n * landing rect) on every target whose drop changes an edge's thickness (a side's width or a bar's height): strips,\n * new-column lines, rails and gaps. A rail drop strip (`armedHit`) doesn't carry it.\n */\n readonly roomHit?: Rect;\n}\n\n/**\n * Where a refusal ranks in the pick (the drag intent's `REFUSAL_RANK`, the same value): an ordering rank, not a\n * priority. Priorities stay the integers 1, 2 and 3; a refusal's tier is `refuse: true`, ordered by this rank on the\n * same scale: after every target of priority 1 and 2, so a real target wins wherever the two meet or overlap, and\n * before priority 3 (the float).\n */\nexport const REFUSAL_RANK = 2.5;\n\n/** A target's rank in the pick: its `priority`, a refusal's {@link REFUSAL_RANK}. Lower wins. */\nexport const pickRank = (t: { readonly priority: number; readonly refuse?: true }): number => (t.refuse === true ? REFUSAL_RANK : t.priority);\n"],"mappings":";;;;;;;;;;;;;;;AA8DO,IAAM,eAAe;AAGrB,IAAM,WAAW,CAAC,MAAsE,EAAE,WAAW,OAAO,eAAe,EAAE;","names":[]}
|
package/dist/popup.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { P as Point, R as Rect, S as Size } from './geometry-L5gCoiZV.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @n-uf/placement/popup: placing a popup (a drop label, a menu, a tooltip) the way Wayland's xdg-positioner does: an
|
|
5
|
+
* anchor point on the anchor rect, a gravity, an offset, then the constraint adjustments in order per axis: flip,
|
|
6
|
+
* slide, resize.
|
|
7
|
+
*
|
|
8
|
+
* See docs/placement.md, Entry: popup.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** -1: the start edge (left or top), 0: the center, 1: the end edge. */
|
|
12
|
+
type Align = -1 | 0 | 1;
|
|
13
|
+
/**
|
|
14
|
+
* A rule: the popup's anchor point on the anchor rect, the direction it extends from there (gravity), an offset,
|
|
15
|
+
* and which adjustments are allowed: flip (mirror anchor, gravity and offset; kept only if that fits), then slide
|
|
16
|
+
* (move inside, the start edge winning), then resize (cut to the bounds).
|
|
17
|
+
*/
|
|
18
|
+
interface PositionerRule {
|
|
19
|
+
readonly anchor: {
|
|
20
|
+
readonly x: Align;
|
|
21
|
+
readonly y: Align;
|
|
22
|
+
};
|
|
23
|
+
readonly gravity: {
|
|
24
|
+
readonly x: Align;
|
|
25
|
+
readonly y: Align;
|
|
26
|
+
};
|
|
27
|
+
readonly offset: Point;
|
|
28
|
+
readonly flip: boolean;
|
|
29
|
+
readonly slide: boolean;
|
|
30
|
+
readonly resize: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface Positioned {
|
|
33
|
+
readonly rect: Rect;
|
|
34
|
+
readonly flipped: {
|
|
35
|
+
readonly x: boolean;
|
|
36
|
+
readonly y: boolean;
|
|
37
|
+
};
|
|
38
|
+
readonly slid: {
|
|
39
|
+
readonly x: boolean;
|
|
40
|
+
readonly y: boolean;
|
|
41
|
+
};
|
|
42
|
+
readonly resized: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** Where a popup of `size` goes for `anchorRect` by `rule`, kept inside `bounds` as far as the rule allows. */
|
|
45
|
+
declare function positionPopup(anchorRect: Rect, size: Size, bounds: Rect, rule: PositionerRule): Positioned;
|
|
46
|
+
/** Below the anchor's bottom-left corner, extending right and down, 6 px apart; flips, slides and resizes. */
|
|
47
|
+
declare const BELOW_LEFT: PositionerRule;
|
|
48
|
+
|
|
49
|
+
export { type Align, BELOW_LEFT, type Positioned, type PositionerRule, positionPopup };
|
package/dist/popup.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/popup/index.ts
|
|
2
|
+
function placeAxis(a0, alen, anchor, gravity, offset, size) {
|
|
3
|
+
const point = a0 + (anchor + 1) / 2 * alen + offset;
|
|
4
|
+
return gravity === 1 ? point : gravity === -1 ? point - size : point - size / 2;
|
|
5
|
+
}
|
|
6
|
+
function positionPopup(anchorRect, size, bounds, rule) {
|
|
7
|
+
const axes = [
|
|
8
|
+
{ a0: anchorRect.x, alen: anchorRect.width, anchor: rule.anchor.x, gravity: rule.gravity.x, offset: rule.offset.x, size: size.width, b0: bounds.x, blen: bounds.width },
|
|
9
|
+
{ a0: anchorRect.y, alen: anchorRect.height, anchor: rule.anchor.y, gravity: rule.gravity.y, offset: rule.offset.y, size: size.height, b0: bounds.y, blen: bounds.height }
|
|
10
|
+
];
|
|
11
|
+
const out = axes.map((ax) => {
|
|
12
|
+
const fits = (start2, len2) => start2 >= ax.b0 - 0.01 && start2 + len2 <= ax.b0 + ax.blen + 0.01;
|
|
13
|
+
let start = placeAxis(ax.a0, ax.alen, ax.anchor, ax.gravity, ax.offset, ax.size);
|
|
14
|
+
let len = ax.size;
|
|
15
|
+
let flipped = false;
|
|
16
|
+
let slid = false;
|
|
17
|
+
let resized = false;
|
|
18
|
+
if (!fits(start, len) && rule.flip && (ax.anchor !== 0 || ax.gravity !== 0)) {
|
|
19
|
+
const mirrored = placeAxis(ax.a0, ax.alen, -ax.anchor, -ax.gravity, -ax.offset, ax.size);
|
|
20
|
+
if (fits(mirrored, len)) {
|
|
21
|
+
start = mirrored;
|
|
22
|
+
flipped = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!fits(start, len) && rule.slide) {
|
|
26
|
+
if (start + len > ax.b0 + ax.blen) start = ax.b0 + ax.blen - len;
|
|
27
|
+
if (start < ax.b0) start = ax.b0;
|
|
28
|
+
slid = true;
|
|
29
|
+
}
|
|
30
|
+
if (!fits(start, len) && rule.resize) {
|
|
31
|
+
const end = Math.min(start + len, ax.b0 + ax.blen);
|
|
32
|
+
start = Math.max(start, ax.b0);
|
|
33
|
+
len = Math.max(0, end - start);
|
|
34
|
+
resized = true;
|
|
35
|
+
}
|
|
36
|
+
return { start, len, flipped, slid, resized };
|
|
37
|
+
});
|
|
38
|
+
const [x, y] = out;
|
|
39
|
+
return {
|
|
40
|
+
rect: { x: x.start, y: y.start, width: x.len, height: y.len },
|
|
41
|
+
flipped: { x: x.flipped, y: y.flipped },
|
|
42
|
+
slid: { x: x.slid, y: y.slid },
|
|
43
|
+
resized: x.resized || y.resized
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var BELOW_LEFT = {
|
|
47
|
+
anchor: { x: -1, y: 1 },
|
|
48
|
+
gravity: { x: 1, y: 1 },
|
|
49
|
+
offset: { x: 0, y: 6 },
|
|
50
|
+
flip: true,
|
|
51
|
+
slide: true,
|
|
52
|
+
resize: true
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
BELOW_LEFT,
|
|
56
|
+
positionPopup
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=popup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/popup/index.ts"],"sourcesContent":["/**\n * @n-uf/placement/popup: placing a popup (a drop label, a menu, a tooltip) the way Wayland's xdg-positioner does: an\n * anchor point on the anchor rect, a gravity, an offset, then the constraint adjustments in order per axis: flip,\n * slide, resize.\n *\n * See docs/placement.md, Entry: popup.\n */\nimport type { Point, Rect, Size } from \"../geometry\";\n\n/** -1: the start edge (left or top), 0: the center, 1: the end edge. */\nexport type Align = -1 | 0 | 1;\n\n/**\n * A rule: the popup's anchor point on the anchor rect, the direction it extends from there (gravity), an offset,\n * and which adjustments are allowed: flip (mirror anchor, gravity and offset; kept only if that fits), then slide\n * (move inside, the start edge winning), then resize (cut to the bounds).\n */\nexport interface PositionerRule {\n readonly anchor: { readonly x: Align; readonly y: Align };\n readonly gravity: { readonly x: Align; readonly y: Align };\n readonly offset: Point;\n readonly flip: boolean;\n readonly slide: boolean;\n readonly resize: boolean;\n}\n\nexport interface Positioned {\n readonly rect: Rect;\n readonly flipped: { readonly x: boolean; readonly y: boolean };\n readonly slid: { readonly x: boolean; readonly y: boolean };\n readonly resized: boolean;\n}\n\nfunction placeAxis(a0: number, alen: number, anchor: Align, gravity: Align, offset: number, size: number): number {\n const point = a0 + ((anchor + 1) / 2) * alen + offset;\n return gravity === 1 ? point : gravity === -1 ? point - size : point - size / 2;\n}\n\n/** Where a popup of `size` goes for `anchorRect` by `rule`, kept inside `bounds` as far as the rule allows. */\nexport function positionPopup(anchorRect: Rect, size: Size, bounds: Rect, rule: PositionerRule): Positioned {\n const axes = [\n { a0: anchorRect.x, alen: anchorRect.width, anchor: rule.anchor.x, gravity: rule.gravity.x, offset: rule.offset.x, size: size.width, b0: bounds.x, blen: bounds.width },\n { a0: anchorRect.y, alen: anchorRect.height, anchor: rule.anchor.y, gravity: rule.gravity.y, offset: rule.offset.y, size: size.height, b0: bounds.y, blen: bounds.height },\n ];\n const out = axes.map((ax) => {\n const fits = (start: number, len: number): boolean => start >= ax.b0 - 0.01 && start + len <= ax.b0 + ax.blen + 0.01;\n let start = placeAxis(ax.a0, ax.alen, ax.anchor, ax.gravity, ax.offset, ax.size);\n let len = ax.size;\n let flipped = false;\n let slid = false;\n let resized = false;\n if (!fits(start, len) && rule.flip && (ax.anchor !== 0 || ax.gravity !== 0)) {\n const mirrored = placeAxis(ax.a0, ax.alen, -ax.anchor as Align, -ax.gravity as Align, -ax.offset, ax.size);\n if (fits(mirrored, len)) {\n start = mirrored;\n flipped = true;\n }\n }\n if (!fits(start, len) && rule.slide) {\n if (start + len > ax.b0 + ax.blen) start = ax.b0 + ax.blen - len;\n if (start < ax.b0) start = ax.b0;\n slid = true;\n }\n if (!fits(start, len) && rule.resize) {\n const end = Math.min(start + len, ax.b0 + ax.blen);\n start = Math.max(start, ax.b0);\n len = Math.max(0, end - start);\n resized = true;\n }\n return { start, len, flipped, slid, resized };\n });\n const [x, y] = out as [(typeof out)[0], (typeof out)[0]];\n return {\n rect: { x: x.start, y: y.start, width: x.len, height: y.len },\n flipped: { x: x.flipped, y: y.flipped },\n slid: { x: x.slid, y: y.slid },\n resized: x.resized || y.resized,\n };\n}\n\n/** Below the anchor's bottom-left corner, extending right and down, 6 px apart; flips, slides and resizes. */\nexport const BELOW_LEFT: PositionerRule = {\n anchor: { x: -1, y: 1 },\n gravity: { x: 1, y: 1 },\n offset: { x: 0, y: 6 },\n flip: true,\n slide: true,\n resize: true,\n};\n"],"mappings":";AAiCA,SAAS,UAAU,IAAY,MAAc,QAAe,SAAgB,QAAgB,MAAsB;AAChH,QAAM,QAAQ,MAAO,SAAS,KAAK,IAAK,OAAO;AAC/C,SAAO,YAAY,IAAI,QAAQ,YAAY,KAAK,QAAQ,OAAO,QAAQ,OAAO;AAChF;AAGO,SAAS,cAAc,YAAkB,MAAY,QAAc,MAAkC;AAC1G,QAAM,OAAO;AAAA,IACX,EAAE,IAAI,WAAW,GAAG,MAAM,WAAW,OAAO,QAAQ,KAAK,OAAO,GAAG,SAAS,KAAK,QAAQ,GAAG,QAAQ,KAAK,OAAO,GAAG,MAAM,KAAK,OAAO,IAAI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