elements-kit 0.27.6 → 0.27.8
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/dist/ui/overlay/index.d.mts +12 -11
- package/dist/ui/overlay/index.mjs +11 -12
- package/package.json +1 -1
|
@@ -78,12 +78,17 @@ type NoInline = {
|
|
|
78
78
|
* both edges of one axis.
|
|
79
79
|
*/
|
|
80
80
|
type Boundary = (BlockEdge & InlineEdge) | (BlockEdge & NoInline) | (NoBlock & InlineEdge);
|
|
81
|
+
/** Where {@link Region.place} puts a box's top-left corner. */
|
|
82
|
+
interface Placement {
|
|
83
|
+
readonly x: number;
|
|
84
|
+
readonly y: number;
|
|
85
|
+
}
|
|
81
86
|
/**
|
|
82
87
|
* Somewhere a box may go: a semi-bounded plane, each axis pinned or free.
|
|
83
88
|
* `place` is the only operation: it never writes, so the caller picks which
|
|
84
89
|
* channels to take — `box.x = region.place(box).x` moves one axis and leaves
|
|
85
|
-
* the rest.
|
|
86
|
-
* rather than shrinks, as CSS does.
|
|
90
|
+
* the rest. Size is never returned: the box is placed as given, so one larger
|
|
91
|
+
* than its room overflows rather than shrinks, as CSS does.
|
|
87
92
|
*
|
|
88
93
|
* The four insets read back as CSS would want them: the pinned edge's
|
|
89
94
|
* coordinate, `null` for the other three (`auto`). A centred axis is not an
|
|
@@ -94,13 +99,8 @@ interface Region {
|
|
|
94
99
|
readonly right: number | null;
|
|
95
100
|
readonly top: number | null;
|
|
96
101
|
readonly bottom: number | null;
|
|
97
|
-
place(box: ReadonlyBox):
|
|
102
|
+
place(box: ReadonlyBox): Placement;
|
|
98
103
|
}
|
|
99
|
-
/** One axis of a {@link Region.place}: where a box `n` long, currently at
|
|
100
|
-
* `own`, starts once `pin` is honoured. */
|
|
101
|
-
declare function placeAxis(pin: Pin, own: number, n: number): number;
|
|
102
|
-
/** The inset a pin yields on one edge: its coordinate if it pins that edge. */
|
|
103
|
-
declare function inset(pin: Pin, edge: "start" | "end"): number | null;
|
|
104
104
|
/**
|
|
105
105
|
* A {@link Region} driven by writes — for gestures, where the box grows away
|
|
106
106
|
* from the edge the user is not dragging. Assigning an inset pins that edge
|
|
@@ -117,7 +117,7 @@ declare class MutableRegion implements Region {
|
|
|
117
117
|
set right(v: number | null);
|
|
118
118
|
set top(v: number | null);
|
|
119
119
|
set bottom(v: number | null);
|
|
120
|
-
place(box: ReadonlyBox):
|
|
120
|
+
place(box: ReadonlyBox): Placement;
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/ui/overlay/anchor.d.ts
|
|
@@ -176,7 +176,8 @@ declare class PositionArea implements Region, ReadonlyBox {
|
|
|
176
176
|
get right(): number | null;
|
|
177
177
|
get top(): number | null;
|
|
178
178
|
get bottom(): number | null;
|
|
179
|
-
|
|
179
|
+
/** Every axis is pinned, so only the box's size is read. */
|
|
180
|
+
place(box: Pick<ReadonlyBox, "w" | "h">): Placement;
|
|
180
181
|
}
|
|
181
182
|
//#endregion
|
|
182
183
|
//#region src/ui/overlay/overlay.d.ts
|
|
@@ -265,4 +266,4 @@ declare class Motion implements IMotion {
|
|
|
265
266
|
abort(initial?: number): void;
|
|
266
267
|
}
|
|
267
268
|
//#endregion
|
|
268
|
-
export { type Align, type Axis, type BlockSide, type Boundary, ElementBox, gestures_d_exports as Gestures, type IDirection, type IMotion, type InlineSide, type Inset, Motion, MutableRegion, OverlayBox, type PhysicalInset, type Pin, PositionArea, type ReadonlyBox, type Region, WINDOW_BOX, WindowBox, anchor_length
|
|
269
|
+
export { type Align, type Axis, type BlockSide, type Boundary, ElementBox, gestures_d_exports as Gestures, type IDirection, type IMotion, type InlineSide, type Inset, Motion, MutableRegion, OverlayBox, type PhysicalInset, type Pin, type Placement, PositionArea, type ReadonlyBox, type Region, WINDOW_BOX, WindowBox, anchor_length };
|
|
@@ -6,14 +6,16 @@ import { direction } from "../../utilities/direction.mjs";
|
|
|
6
6
|
import { createElementRect } from "../../utilities/element-rect.mjs";
|
|
7
7
|
import { windowSize } from "../../utilities/window-size.mjs";
|
|
8
8
|
//#region src/ui/overlay/area.ts
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
function placeAxis(pin, own, n) {
|
|
12
|
-
if (!pin) return own;
|
|
9
|
+
/** Where a box `n` long starts on a pinned axis. */
|
|
10
|
+
function placePinned(pin, n) {
|
|
13
11
|
if (pin.align === "start") return pin.at;
|
|
14
12
|
if (pin.align === "end") return pin.at - n;
|
|
15
13
|
return pin.at - n / 2;
|
|
16
14
|
}
|
|
15
|
+
/** One axis of a {@link Region.place}: pinned, or `own` if the axis is free. */
|
|
16
|
+
function placeAxis(pin, own, n) {
|
|
17
|
+
return pin ? placePinned(pin, n) : own;
|
|
18
|
+
}
|
|
17
19
|
/** The inset a pin yields on one edge: its coordinate if it pins that edge. */
|
|
18
20
|
function inset(pin, edge) {
|
|
19
21
|
return pin?.align === edge ? pin.at : null;
|
|
@@ -72,9 +74,7 @@ var MutableRegion = class {
|
|
|
72
74
|
place(box) {
|
|
73
75
|
return {
|
|
74
76
|
x: placeAxis(this.#x(), box.x, box.w),
|
|
75
|
-
y: placeAxis(this.#y(), box.y, box.h)
|
|
76
|
-
w: box.w,
|
|
77
|
-
h: box.h
|
|
77
|
+
y: placeAxis(this.#y(), box.y, box.h)
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
};
|
|
@@ -364,12 +364,11 @@ var PositionArea = class {
|
|
|
364
364
|
get bottom() {
|
|
365
365
|
return inset(this.#py, "end");
|
|
366
366
|
}
|
|
367
|
+
/** Every axis is pinned, so only the box's size is read. */
|
|
367
368
|
place(box) {
|
|
368
369
|
return {
|
|
369
|
-
x:
|
|
370
|
-
y:
|
|
371
|
-
w: box.w,
|
|
372
|
-
h: box.h
|
|
370
|
+
x: placePinned(this.#px, box.w),
|
|
371
|
+
y: placePinned(this.#py, box.h)
|
|
373
372
|
};
|
|
374
373
|
}
|
|
375
374
|
};
|
|
@@ -721,4 +720,4 @@ var Motion = class {
|
|
|
721
720
|
}
|
|
722
721
|
};
|
|
723
722
|
//#endregion
|
|
724
|
-
export { ElementBox, gestures_exports as Gestures, Motion, MutableRegion, OverlayBox, PositionArea, WINDOW_BOX, WindowBox, anchor_length
|
|
723
|
+
export { ElementBox, gestures_exports as Gestures, Motion, MutableRegion, OverlayBox, PositionArea, WINDOW_BOX, WindowBox, anchor_length };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elements-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.8",
|
|
5
5
|
"description": "A lightweight reactive UI library that transforms native HTMLElements into reactive components with signals. Ideal for framework-agnostic applications and web components.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"webcomponents",
|