elements-kit 0.27.7 → 0.27.9
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.
|
@@ -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,7 +99,7 @@ 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
104
|
/**
|
|
100
105
|
* A {@link Region} driven by writes — for gestures, where the box grows away
|
|
@@ -112,7 +117,7 @@ declare class MutableRegion implements Region {
|
|
|
112
117
|
set right(v: number | null);
|
|
113
118
|
set top(v: number | null);
|
|
114
119
|
set bottom(v: number | null);
|
|
115
|
-
place(box: ReadonlyBox):
|
|
120
|
+
place(box: ReadonlyBox): Placement;
|
|
116
121
|
}
|
|
117
122
|
//#endregion
|
|
118
123
|
//#region src/ui/overlay/anchor.d.ts
|
|
@@ -139,6 +144,23 @@ type Inset = PhysicalInset | "inset-block-start" | "inset-block-end" | "inset-in
|
|
|
139
144
|
* box's reactive geometry, so calling it inside an `effect` tracks the anchor.
|
|
140
145
|
*/
|
|
141
146
|
declare function anchor_length(box: Box & Partial<IDirection>, inset: Inset, side: BlockSide | InlineSide | number): number;
|
|
147
|
+
/** Keywords naming the block axis. */
|
|
148
|
+
type BlockKeyword = "top" | "bottom" | "span-top" | "span-bottom" | "block-start" | "block-end" | "span-block-start" | "span-block-end" | "y-start" | "y-end" | "span-y-start" | "span-y-end";
|
|
149
|
+
/** Keywords naming the inline axis. */
|
|
150
|
+
type InlineKeyword = "left" | "right" | "span-left" | "span-right" | "inline-start" | "inline-end" | "span-inline-start" | "span-inline-end" | "x-start" | "x-end" | "span-x-start" | "span-x-end";
|
|
151
|
+
/** Keywords naming no axis — each takes whichever one is still free. */
|
|
152
|
+
type AmbiguousKeyword = "center" | "span-all" | "start" | "end" | "span-start" | "span-end" | "self-start" | "self-end" | "span-self-start" | "span-self-end";
|
|
153
|
+
type AreaKeyword = BlockKeyword | InlineKeyword | AmbiguousKeyword;
|
|
154
|
+
/** Two keywords, in either order — `position-area` is unordered. */
|
|
155
|
+
type Unordered<A extends string, B extends string> = `${A} ${B}` | `${B} ${A}`;
|
|
156
|
+
/**
|
|
157
|
+
* A valid `position-area` value: one keyword, or two naming different axes.
|
|
158
|
+
* Two of the same explicit axis (`top bottom`, `left right`) is not a value —
|
|
159
|
+
* {@link resolveArea} resolves anything invalid to the `block-end` fallback,
|
|
160
|
+
* so catching it here is the difference between a compile error and a menu
|
|
161
|
+
* that quietly opens on the wrong side.
|
|
162
|
+
*/
|
|
163
|
+
type PositionAreaValue = AreaKeyword | Unordered<BlockKeyword, InlineKeyword> | Unordered<BlockKeyword, AmbiguousKeyword> | Unordered<InlineKeyword, AmbiguousKeyword> | `${AmbiguousKeyword} ${AmbiguousKeyword}`;
|
|
142
164
|
/**
|
|
143
165
|
* The reactive `position-area` property: the region of the viewport an
|
|
144
166
|
* overlay anchored to `anchor` may occupy, with the region's default
|
|
@@ -162,7 +184,7 @@ declare function anchor_length(box: Box & Partial<IDirection>, inset: Inset, sid
|
|
|
162
184
|
declare class PositionArea implements Region, ReadonlyBox {
|
|
163
185
|
#private;
|
|
164
186
|
readonly anchor: ReadonlyBox;
|
|
165
|
-
constructor(anchor: ReadonlyBox, area:
|
|
187
|
+
constructor(anchor: ReadonlyBox, area: PositionAreaValue);
|
|
166
188
|
get x(): number;
|
|
167
189
|
get y(): number;
|
|
168
190
|
get w(): number;
|
|
@@ -172,7 +194,7 @@ declare class PositionArea implements Region, ReadonlyBox {
|
|
|
172
194
|
get top(): number | null;
|
|
173
195
|
get bottom(): number | null;
|
|
174
196
|
/** Every axis is pinned, so only the box's size is read. */
|
|
175
|
-
place(box: Pick<ReadonlyBox, "w" | "h">):
|
|
197
|
+
place(box: Pick<ReadonlyBox, "w" | "h">): Placement;
|
|
176
198
|
}
|
|
177
199
|
//#endregion
|
|
178
200
|
//#region src/ui/overlay/overlay.d.ts
|
|
@@ -261,4 +283,4 @@ declare class Motion implements IMotion {
|
|
|
261
283
|
abort(initial?: number): void;
|
|
262
284
|
}
|
|
263
285
|
//#endregion
|
|
264
|
-
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 };
|
|
286
|
+
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 PositionAreaValue, type ReadonlyBox, type Region, WINDOW_BOX, WindowBox, anchor_length };
|
|
@@ -74,9 +74,7 @@ var MutableRegion = class {
|
|
|
74
74
|
place(box) {
|
|
75
75
|
return {
|
|
76
76
|
x: placeAxis(this.#x(), box.x, box.w),
|
|
77
|
-
y: placeAxis(this.#y(), box.y, box.h)
|
|
78
|
-
w: box.w,
|
|
79
|
-
h: box.h
|
|
77
|
+
y: placeAxis(this.#y(), box.y, box.h)
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
80
|
};
|
|
@@ -183,7 +181,8 @@ const A = (region, self = false) => ({
|
|
|
183
181
|
physical: false,
|
|
184
182
|
self
|
|
185
183
|
});
|
|
186
|
-
/** The full `position-area` keyword grammar → axis + physical region.
|
|
184
|
+
/** The full `position-area` keyword grammar → axis + physical region. The
|
|
185
|
+
* key type forces this table and {@link PositionAreaValue} to stay in step. */
|
|
187
186
|
const KEYWORDS = {
|
|
188
187
|
top: B("start", true),
|
|
189
188
|
bottom: B("end", true),
|
|
@@ -370,9 +369,7 @@ var PositionArea = class {
|
|
|
370
369
|
place(box) {
|
|
371
370
|
return {
|
|
372
371
|
x: placePinned(this.#px, box.w),
|
|
373
|
-
y: placePinned(this.#py, box.h)
|
|
374
|
-
w: box.w,
|
|
375
|
-
h: box.h
|
|
372
|
+
y: placePinned(this.#py, box.h)
|
|
376
373
|
};
|
|
377
374
|
}
|
|
378
375
|
};
|
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.9",
|
|
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",
|