elements-kit 0.27.5 → 0.27.7
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/attributes.d.mts +1 -1
- package/dist/await.d.mts +1 -1
- package/dist/await.mjs +1 -1
- package/dist/{children-_cMdyX7Q.d.mts → children-CjlmAzxx.d.mts} +3 -3
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/{custom-elements-C7oiqw-y.d.mts → custom-elements-CTqSkWI7.d.mts} +1 -1
- package/dist/custom-elements.d.mts +1 -1
- package/dist/direction-EwIAAn1f.d.mts +29 -0
- package/dist/{element-DgQvp-49.mjs → element-bMvwF1ue.mjs} +2 -2
- package/dist/for.d.mts +1 -1
- package/dist/for.mjs +2 -2
- package/dist/{fragment-BJfcQdsL.mjs → fragment-DV0hrE_A.mjs} +2 -2
- package/dist/{hot-eP6QROpU.mjs → hot-kRKLQS6B.mjs} +2 -2
- package/dist/hydrate/index.mjs +1 -1
- package/dist/{hydrate-ICXw1FIY.mjs → hydrate-Vx_iBMqJ.mjs} +3 -3
- package/dist/integrations/astro-client.mjs +3 -3
- package/dist/integrations/astro-server.mjs +3 -3
- package/dist/integrations/astro-slots.mjs +2 -2
- package/dist/integrations/hmr-runtime.mjs +2 -2
- package/dist/integrations/react.d.mts +1 -1
- package/dist/integrations/react.mjs +2 -2
- package/dist/jsx-runtime/dev.d.mts +2 -2
- package/dist/jsx-runtime/dev.mjs +2 -2
- package/dist/jsx-runtime/index.d.mts +2 -2
- package/dist/jsx-runtime/index.mjs +2 -2
- package/dist/render.mjs +1 -1
- package/dist/{scope-C1vELXqP.mjs → scope-B1kDu4YX.mjs} +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/{server-CoEm-C0I.mjs → server-DxiXDjQU.mjs} +3 -3
- package/dist/signals/index.d.mts +1 -1
- package/dist/signals/index.mjs +2 -2
- package/dist/slot.mjs +1 -1
- package/dist/ui/otp-input/index.d.mts +2 -2
- package/dist/ui/otp-input/index.mjs +1 -1
- package/dist/ui/overlay/handle.css +134 -0
- package/dist/ui/overlay/index.css +13 -88
- package/dist/ui/overlay/index.d.mts +228 -347
- package/dist/ui/overlay/index.mjs +679 -1550
- package/dist/ui/overlay/overlay.css +74 -135
- package/dist/utilities/_observe.mjs +1 -1
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/active-element.mjs +1 -1
- package/dist/utilities/async.d.mts +1 -1
- package/dist/utilities/async.mjs +1 -1
- package/dist/utilities/context.mjs +1 -1
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/debounced.mjs +1 -1
- package/dist/utilities/direction.d.mts +2 -0
- package/dist/utilities/direction.mjs +42 -0
- package/dist/utilities/dom-lifecycle.bench.mjs +2 -2
- package/dist/utilities/dom-lifecycle.d.mts +1 -1
- package/dist/utilities/dom-lifecycle.mjs +1 -1
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-rect.mjs +1 -1
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/environment.d.mts +1 -1
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-driven.mjs +1 -1
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/event-listener.mjs +1 -1
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/focus-within.mjs +1 -1
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/hover.mjs +1 -1
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/interval.mjs +1 -1
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/location.mjs +1 -1
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-devices.mjs +1 -1
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/media-query.mjs +1 -1
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/network.mjs +1 -1
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/orientation.mjs +1 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/previous.mjs +1 -1
- package/dist/utilities/promise.d.mts +1 -1
- package/dist/utilities/promise.mjs +1 -1
- package/dist/utilities/retry.mjs +1 -1
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/routing.mjs +1 -1
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/storage.d.mts +1 -1
- package/dist/utilities/storage.mjs +1 -1
- package/dist/utilities/throttled.d.mts +1 -1
- package/dist/utilities/throttled.mjs +1 -1
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/timeout.mjs +1 -1
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-focus.mjs +1 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/dist/utilities/window-size.mjs +1 -1
- package/package.json +7 -3
- /package/dist/{attributes-3r7Diua4.d.mts → attributes-YQZNO15D.d.mts} +0 -0
- /package/dist/{environment-c2ftMYT0.d.mts → environment-EQugnOcg.d.mts} +0 -0
- /package/dist/{index-BrVMftR8.d.mts → index-BSAqa0-0.d.mts} +0 -0
- /package/dist/{lib-DYypKhxk.mjs → lib-Dw0g-vex.mjs} +0 -0
- /package/dist/{polyfill-CdZVCxdo.mjs → polyfill-B1lNNcum.mjs} +0 -0
- /package/dist/{polyfill-BVNd6ogU.d.mts → polyfill-_7qvybvt.d.mts} +0 -0
|
@@ -1,383 +1,264 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as MaybeReactive } from "../../index-BSAqa0-0.mjs";
|
|
2
|
+
import { t as Direction } from "../../direction-EwIAAn1f.mjs";
|
|
2
3
|
|
|
3
|
-
//#region src/ui/overlay/
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* applies a region to an overlay by syncing it into the
|
|
9
|
-
* `--overlay-constraint-top/-left/-width/-height` channels every location
|
|
10
|
-
* clamp and gesture bound derives from (declared in index.css with
|
|
11
|
-
* viewport defaults). Derived values build on regions — `detents()`
|
|
12
|
-
* quantizes one, `rubber()` resists at its edges.
|
|
13
|
-
*/
|
|
14
|
-
/** A reactive rect. `createElementRect` returns one reactive `DOMRect`,
|
|
15
|
-
* so the element branch projects its fields onto this shape; custom
|
|
16
|
-
* rects (a static region, a virtual area) can be supplied too. */
|
|
17
|
-
interface Region {
|
|
18
|
-
top(): number;
|
|
19
|
-
left(): number;
|
|
20
|
-
width(): number;
|
|
21
|
-
height(): number;
|
|
4
|
+
//#region src/ui/overlay/box.d.ts
|
|
5
|
+
/** The channel axes a box value moves along. */
|
|
6
|
+
type Axis = keyof ReadonlyBox;
|
|
7
|
+
interface IDirection {
|
|
8
|
+
readonly direction: "ltr" | "rtl";
|
|
22
9
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
height: number;
|
|
10
|
+
interface ReadonlyBox {
|
|
11
|
+
readonly x: number;
|
|
12
|
+
readonly y: number;
|
|
13
|
+
readonly w: number;
|
|
14
|
+
readonly h: number;
|
|
29
15
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
declare
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
interface Box extends ReadonlyBox {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
w: number;
|
|
20
|
+
h: number;
|
|
21
|
+
}
|
|
22
|
+
declare class WindowBox implements ReadonlyBox, IDirection {
|
|
23
|
+
get x(): number;
|
|
24
|
+
get y(): number;
|
|
25
|
+
get w(): number;
|
|
26
|
+
get h(): number;
|
|
27
|
+
get direction(): Direction;
|
|
28
|
+
}
|
|
29
|
+
declare const WINDOW_BOX: WindowBox;
|
|
30
|
+
declare class ElementBox implements ReadonlyBox {
|
|
31
|
+
#private;
|
|
32
|
+
constructor(el: MaybeReactive<Element>);
|
|
39
33
|
[Symbol.dispose](): void;
|
|
34
|
+
get x(): number;
|
|
35
|
+
get y(): number;
|
|
36
|
+
get w(): number;
|
|
37
|
+
get h(): number;
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/ui/overlay/area.d.ts
|
|
41
|
+
/** Which of a box's points sits on a pin: its lo edge, hi edge, or middle. */
|
|
42
|
+
type Align = "start" | "end" | "center";
|
|
43
|
+
/** One axis of a region: a coordinate and the box point that sits on it,
|
|
44
|
+
* or `null` — the axis is free and the box keeps its own coordinate. */
|
|
45
|
+
type Pin = {
|
|
46
|
+
readonly align: Align;
|
|
47
|
+
readonly at: number;
|
|
48
|
+
} | null;
|
|
49
|
+
/** A pinned block edge and its coordinate. */
|
|
50
|
+
type BlockEdge = {
|
|
50
51
|
top: number;
|
|
52
|
+
bottom?: never;
|
|
53
|
+
} | {
|
|
54
|
+
bottom: number;
|
|
55
|
+
top?: never;
|
|
56
|
+
};
|
|
57
|
+
/** A pinned inline edge and its coordinate. */
|
|
58
|
+
type InlineEdge = {
|
|
51
59
|
left: number;
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
right?: never;
|
|
61
|
+
} | {
|
|
62
|
+
right: number;
|
|
63
|
+
left?: never;
|
|
64
|
+
};
|
|
65
|
+
/** Neither block edge pinned — the axis is free. */
|
|
66
|
+
type NoBlock = {
|
|
67
|
+
top?: never;
|
|
68
|
+
bottom?: never;
|
|
69
|
+
};
|
|
70
|
+
/** Neither inline edge pinned — the axis is free. */
|
|
71
|
+
type NoInline = {
|
|
72
|
+
left?: never;
|
|
73
|
+
right?: never;
|
|
54
74
|
};
|
|
55
75
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* region changes.
|
|
60
|
-
*
|
|
61
|
-
* Caveat: an element region observes size changes (`ResizeObserver`) — a
|
|
62
|
-
* container that moves without resizing (e.g. page scroll) does not
|
|
63
|
-
* retrigger the sync.
|
|
64
|
-
*
|
|
65
|
-
* Registers its cleanup with the current scope (`onCleanup`) and also
|
|
66
|
-
* returns it as `dispose` / `Symbol.dispose`; disposing removes the
|
|
67
|
-
* variables, restoring the viewport constraint.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* import { constraint, confine } from "elements-kit/ui/overlay";
|
|
72
|
-
*
|
|
73
|
-
* const panel = document.querySelector("dialog.x-overlay")!;
|
|
74
|
-
* confine(panel, constraint(document.querySelector("main")!));
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
declare function confine(overlay: HTMLElement, region: Region): OverlayConstraint;
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/ui/overlay/anchor.d.ts
|
|
80
|
-
/**
|
|
81
|
-
* The anchor — one of the two spatial primitives (with the constraint).
|
|
82
|
-
* `anchor(overlay, follow?)` gives the overlay an anchor ELEMENT it
|
|
83
|
-
* follows for its whole life; the anchor element follows `follow` until
|
|
84
|
-
* something else moves it (a `draggable()` service, author code). The
|
|
85
|
-
* overlay itself has no states — dragging, tearing off, re-pinning are
|
|
86
|
-
* all things that happen to the anchor.
|
|
87
|
-
*
|
|
88
|
-
* Two engines, chosen once at wire time, never switched:
|
|
89
|
-
*
|
|
90
|
-
* - Native CSS anchor positioning (compound gate, no `within`/`arrow`):
|
|
91
|
-
* the overlay's `position-anchor` points at the anchor element; when
|
|
92
|
-
* `follow` is an element the anchor pins itself to it through a second
|
|
93
|
-
* native hop (`[data-follow]` rule in index.css mirrors the followed
|
|
94
|
-
* box via `anchor()`/`anchor-size()`). Placement, flip and scroll
|
|
95
|
-
* tracking are compositor-side through both hops — zero JS.
|
|
96
|
-
* - Floating UI (below the gate, or `within`/`arrow` requested — native
|
|
97
|
-
* CSS has no boundary control and no flip signal): `autoUpdate` writes
|
|
98
|
-
* the box center into the `--overlay-x`/`-y` channels while the
|
|
99
|
-
* overlay is open; a `dragmove` event from the drag service triggers
|
|
100
|
-
* an immediate reposition. The initial positioning write is instant;
|
|
101
|
-
* geometry transitions re-enable after it (Base UI's `data-instant`
|
|
102
|
-
* semantics), so re-pins and live area changes morph by the
|
|
103
|
-
* stylesheet. During an anchor drag, writes suppress geometry
|
|
104
|
-
* transitions again — the overlay must not ease behind the finger.
|
|
105
|
-
*
|
|
106
|
-
* `data-anchor="element"` is a static wiring marker (stamped here,
|
|
107
|
-
* removed on dispose, never toggled). `data-placed` is output state —
|
|
108
|
-
* the settled side, feeding the arrow and `transform-origin` (a hint
|
|
109
|
-
* from `--overlay-area` under the native engine, the real side under
|
|
110
|
-
* Floating UI). A first pointer-down from `draggable()` tears the
|
|
111
|
-
* follow pin (the `data-follow` contract); a fresh open re-pins.
|
|
112
|
-
*/
|
|
113
|
-
interface AnchorOptions {
|
|
114
|
-
/** Flip/shift boundary — placement confined to this region instead of
|
|
115
|
-
* the viewport. Forces the Floating UI engine. */
|
|
116
|
-
within?: Region;
|
|
117
|
-
/** Caret pointing at the anchor (`.x-overlay-arrow`, injected when not
|
|
118
|
-
* authored; a number sets `--overlay-arrow-size` in px). Forces the
|
|
119
|
-
* Floating UI engine. */
|
|
120
|
-
arrow?: number | boolean;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Maps a `position-area` value to the Floating UI placement. Spanning
|
|
124
|
-
* toward an edge leaves the box flush with the *opposite* edge, so
|
|
125
|
-
* `span-*-end` is a `-start` alignment (and vice versa) — Floating UI
|
|
126
|
-
* resolves `-start`/`-end` logically, so the span tokens need no dir
|
|
127
|
-
* check; only the physical inline sides do. Unknown values fall back to
|
|
128
|
-
* `bottom` (the CSS default, `block-end`).
|
|
76
|
+
* A corner (one edge pinned on each axis: a tooltip, a popover) or a side
|
|
77
|
+
* (one edge, the other axis free: a bottom sheet). Never empty, and never
|
|
78
|
+
* both edges of one axis.
|
|
129
79
|
*/
|
|
130
|
-
|
|
80
|
+
type Boundary = (BlockEdge & InlineEdge) | (BlockEdge & NoInline) | (NoBlock & InlineEdge);
|
|
131
81
|
/**
|
|
132
|
-
*
|
|
133
|
-
* the
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* `follow` may be a getter reading a signal — re-pinning on change is
|
|
138
|
-
* how a shared popover slides between nav triggers: the native chain
|
|
139
|
-
* glides there on the anchor element's CSS transition; the channel
|
|
140
|
-
* engine lets that one write animate.
|
|
141
|
-
*
|
|
142
|
-
* Registers all cleanup with the current scope (`onCleanup`): the anchor
|
|
143
|
-
* element, the wiring, and the stamped attributes are removed together.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```ts
|
|
147
|
-
* import { anchor, draggable, rubber } from "elements-kit/ui/overlay";
|
|
82
|
+
* Somewhere a box may go: a semi-bounded plane, each axis pinned or free.
|
|
83
|
+
* `place` is the only operation: it never writes, so the caller picks which
|
|
84
|
+
* channels to take — `box.x = region.place(box).x` moves one axis and leaves
|
|
85
|
+
* the rest. The box is placed as given: one larger than its room overflows
|
|
86
|
+
* rather than shrinks, as CSS does.
|
|
148
87
|
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* // shared nav popover — re-anchors (and glides) when the signal changes
|
|
153
|
-
* const active = signal(firstTrigger);
|
|
154
|
-
* anchor(menu, () => active(), { arrow: true });
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
declare function anchor(overlay: HTMLElement, follow?: Element | RectInit | (() => Element | RectInit | null | undefined), opts?: AnchorOptions): HTMLElement;
|
|
158
|
-
//#endregion
|
|
159
|
-
//#region src/ui/overlay/resize-strategy.d.ts
|
|
160
|
-
/**
|
|
161
|
-
* Resize strategies — pluggable policy for a resize drag's live bounds
|
|
162
|
-
* and resting size. Pure (no DOM); the gesture injects the context.
|
|
163
|
-
* Built-in: `freeResize` (default). `detents()` (detents.ts) quantizes a
|
|
164
|
-
* constraint region and doubles as a strategy.
|
|
88
|
+
* The four insets read back as CSS would want them: the pinned edge's
|
|
89
|
+
* coordinate, `null` for the other three (`auto`). A centred axis is not an
|
|
90
|
+
* inset — both its edges are `null`.
|
|
165
91
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
* builds it per drag; `resolve` turns a step value into pixels.
|
|
173
|
-
*/
|
|
174
|
-
interface ResizeContext {
|
|
175
|
-
/** Dragged size along the axis (px, before clamping). */
|
|
176
|
-
size: number;
|
|
177
|
-
/** Size at the gesture's start (px). */
|
|
178
|
-
startSize: number;
|
|
179
|
-
/** Release velocity along the axis (px/ms; positive = shrinking). */
|
|
180
|
-
velocity: number;
|
|
181
|
-
/** Resize axis. */
|
|
182
|
-
axis: "width" | "height";
|
|
183
|
-
/** Hard room the surface may occupy on the axis (px). */
|
|
184
|
-
min: number;
|
|
185
|
-
max: number;
|
|
186
|
-
/** Whether a drag/flick past the minimum may dismiss. */
|
|
187
|
-
dismissible: boolean;
|
|
188
|
-
/** Release velocity (px/ms) past which a sub-minimum release dismisses. */
|
|
189
|
-
velocityThreshold: number;
|
|
190
|
-
/** Resolves a step to px — a number is a fraction of the constraint
|
|
191
|
-
* along the axis; a string is any CSS length. */
|
|
192
|
-
resolve(value: number | string): number;
|
|
92
|
+
interface Region {
|
|
93
|
+
readonly left: number | null;
|
|
94
|
+
readonly right: number | null;
|
|
95
|
+
readonly top: number | null;
|
|
96
|
+
readonly bottom: number | null;
|
|
97
|
+
place(box: ReadonlyBox): Box;
|
|
193
98
|
}
|
|
194
99
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
100
|
+
* A {@link Region} driven by writes — for gestures, where the box grows away
|
|
101
|
+
* from the edge the user is not dragging. Assigning an inset pins that edge
|
|
102
|
+
* and releases its opposite; assigning `null` frees the axis.
|
|
198
103
|
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
104
|
+
declare class MutableRegion implements Region {
|
|
105
|
+
#private;
|
|
106
|
+
constructor(boundary: Boundary);
|
|
107
|
+
get left(): number | null;
|
|
108
|
+
get right(): number | null;
|
|
109
|
+
get top(): number | null;
|
|
110
|
+
get bottom(): number | null;
|
|
111
|
+
set left(v: number | null);
|
|
112
|
+
set right(v: number | null);
|
|
113
|
+
set top(v: number | null);
|
|
114
|
+
set bottom(v: number | null);
|
|
115
|
+
place(box: ReadonlyBox): Box;
|
|
205
116
|
}
|
|
206
|
-
/**
|
|
207
|
-
* Picks the index of the detent closest to the released size, projected
|
|
208
|
-
* along the release velocity (px/ms, positive = shrinking). Returns `-1`
|
|
209
|
-
* when the gesture should dismiss instead.
|
|
210
|
-
*/
|
|
211
|
-
declare function closestDetent(sizePx: number, detentsPx: readonly number[], velocityPxPerMs?: number, dismissible?: boolean, velocityThreshold?: number): number;
|
|
212
|
-
/**
|
|
213
|
-
* Free resize: drag to any size within the room; a flick or shrink past
|
|
214
|
-
* the minimum dismisses. The default strategy.
|
|
215
|
-
*/
|
|
216
|
-
declare function freeResize(opts?: {
|
|
217
|
-
min?: number;
|
|
218
|
-
}): ResizeStrategy;
|
|
219
117
|
//#endregion
|
|
220
|
-
//#region src/ui/overlay/
|
|
221
|
-
/**
|
|
222
|
-
* Detents — a customization of the constraint: the region, quantized.
|
|
223
|
-
* One snapping concept for both services: `resize()` (and the markup
|
|
224
|
-
* gestures) snap extents to the stops; `draggable()` snaps positions to
|
|
225
|
-
* them. A bottom sheet's size detents and its top-edge position detents
|
|
226
|
-
* were always the same thing — here they are literally the same object.
|
|
227
|
-
*/
|
|
228
|
-
/** A {@link Region} with quantized stops. Doubles as a `ResizeStrategy`
|
|
229
|
-
* (the stops resolve per axis through the gesture's `ResizeContext`). */
|
|
230
|
-
interface Space extends ResizeStrategy {
|
|
231
|
-
readonly region: Region;
|
|
232
|
-
readonly stops: readonly (number | string)[];
|
|
233
|
-
/** The numeric stops resolved against a region axis (px, sorted) —
|
|
234
|
-
* position snapping for `draggable()`. String stops (CSS lengths) need
|
|
235
|
-
* an element context and only apply to resizes. */
|
|
236
|
-
positions(axis: "width" | "height"): number[];
|
|
237
|
-
}
|
|
118
|
+
//#region src/ui/overlay/anchor.d.ts
|
|
238
119
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* on release; shrinking past the smallest stop dismisses (when the
|
|
242
|
-
* consumer allows dismissal).
|
|
120
|
+
* The anchor-side vocabulary of the CSS `anchor()` function, reimplemented
|
|
121
|
+
* reactively — the JS tier speaks the same words as the native one:
|
|
243
122
|
*
|
|
244
|
-
*
|
|
245
|
-
* ```ts
|
|
246
|
-
* import { constraint, detents } from "elements-kit/ui/overlay";
|
|
123
|
+
* overlay.y = anchor_length(a, "top", "bottom") ≡ top: anchor(bottom)
|
|
247
124
|
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
125
|
+
* Horizontal writing modes only: the block axis always starts at the top;
|
|
126
|
+
* only the inline axis consults `direction`.
|
|
250
127
|
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
128
|
+
/** Sides valid in a block-axis inset (`top` / `bottom`). */
|
|
129
|
+
type BlockSide = "top" | "bottom" | "inside" | "outside" | "start" | "end" | "self-start" | "self-end" | "center";
|
|
130
|
+
/** Sides valid in an inline-axis inset (`left` / `right`). */
|
|
131
|
+
type InlineSide = "left" | "right" | "inside" | "outside" | "start" | "end" | "self-start" | "self-end" | "center";
|
|
132
|
+
/** The physical inset longhands. */
|
|
133
|
+
type PhysicalInset = "top" | "right" | "bottom" | "left";
|
|
134
|
+
/** Every inset property `anchor()` may sit in. */
|
|
135
|
+
type Inset = PhysicalInset | "inset-block-start" | "inset-block-end" | "inset-inline-start" | "inset-inline-end";
|
|
254
136
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* `rubber()` is the built-in; custom effects are just objects.
|
|
137
|
+
* The reactive `anchor()` function: the viewport coordinate of an anchor line
|
|
138
|
+
* on `box`, in the context of the inset property being computed. Reads the
|
|
139
|
+
* box's reactive geometry, so calling it inside an `effect` tracks the anchor.
|
|
259
140
|
*/
|
|
260
|
-
|
|
261
|
-
/** Transform a live value (px on one axis) against the axis bounds. */
|
|
262
|
-
during?(value: number, bounds: readonly [number, number]): number;
|
|
263
|
-
/** Pick the resting value on release, or `null` to signal dismissal. */
|
|
264
|
-
settle?(value: number, velocity: number, bounds: readonly [number, number]): number | null;
|
|
265
|
-
}
|
|
141
|
+
declare function anchor_length(box: Box & Partial<IDirection>, inset: Inset, side: BlockSide | InlineSide | number): number;
|
|
266
142
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
* drags the overlay, with no overlay state involved.
|
|
143
|
+
* The reactive `position-area` property: the region of the viewport an
|
|
144
|
+
* overlay anchored to `anchor` may occupy, with the region's default
|
|
145
|
+
* self-alignment as {@link Region.place} — outward regions hug the anchor,
|
|
146
|
+
* spans go flush against its far edge, center is `anchor-center`. Nothing is
|
|
147
|
+
* written; the caller takes what it wants from `place`:
|
|
148
|
+
*
|
|
149
|
+
* const area = new PositionArea(a, "top span-left");
|
|
150
|
+
* effect(() => { overlay.x = area.place(overlay).x; });
|
|
151
|
+
*
|
|
152
|
+
* The value is parsed once, at construction; the geometry reads the anchor
|
|
153
|
+
* and window on every access, so reading it inside an `effect` tracks both.
|
|
279
154
|
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* numeric stops when a `detents()` space is given (`null` from a settle
|
|
284
|
-
* = dismiss signal, surfaced on the `dragend` detail). Events on the
|
|
285
|
-
* target: `dragmove` (`{x, y}`) every move, `dragend`
|
|
286
|
-
* (`{x, y, velocity, rest}`) on release.
|
|
155
|
+
* Bounded by the window. A tighter bound (a `Constraint`, a scroll container)
|
|
156
|
+
* is an intersection with the region, so it composes afterwards rather than
|
|
157
|
+
* being a parameter here.
|
|
287
158
|
*
|
|
288
|
-
*
|
|
289
|
-
* the
|
|
159
|
+
* There is no gap parameter, for the same reason CSS has none: the offset off
|
|
160
|
+
* the anchor is the overlay's own `margin`.
|
|
290
161
|
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
162
|
+
declare class PositionArea implements Region, ReadonlyBox {
|
|
163
|
+
#private;
|
|
164
|
+
readonly anchor: ReadonlyBox;
|
|
165
|
+
constructor(anchor: ReadonlyBox, area: string);
|
|
166
|
+
get x(): number;
|
|
167
|
+
get y(): number;
|
|
168
|
+
get w(): number;
|
|
169
|
+
get h(): number;
|
|
170
|
+
get left(): number | null;
|
|
171
|
+
get right(): number | null;
|
|
172
|
+
get top(): number | null;
|
|
173
|
+
get bottom(): number | null;
|
|
174
|
+
/** Every axis is pinned, so only the box's size is read. */
|
|
175
|
+
place(box: Pick<ReadonlyBox, "w" | "h">): Box;
|
|
303
176
|
}
|
|
304
|
-
declare function draggable(target: HTMLElement, space?: Region | Space, ...effects: Effect[]): DragService;
|
|
305
177
|
//#endregion
|
|
306
|
-
//#region src/ui/overlay/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
178
|
+
//#region src/ui/overlay/overlay.d.ts
|
|
179
|
+
declare class PartialBox implements Partial<Box> {
|
|
180
|
+
x: number | undefined;
|
|
181
|
+
y: number | undefined;
|
|
182
|
+
w: number | undefined;
|
|
183
|
+
h: number | undefined;
|
|
184
|
+
constructor(x?: number | undefined, y?: number | undefined, w?: number | undefined, h?: number | undefined);
|
|
185
|
+
}
|
|
186
|
+
declare class TransformableBox implements ReadonlyBox, Transformable {
|
|
187
|
+
readonly transform: PartialBox;
|
|
188
|
+
readonly displacement: Displacement;
|
|
189
|
+
constructor(transform?: PartialBox);
|
|
190
|
+
get x(): number;
|
|
191
|
+
set x(value: number);
|
|
192
|
+
get y(): number;
|
|
193
|
+
set y(value: number);
|
|
194
|
+
get w(): number;
|
|
195
|
+
set w(value: number);
|
|
196
|
+
get h(): number;
|
|
197
|
+
set h(value: number);
|
|
198
|
+
}
|
|
199
|
+
declare class Displacement extends PartialBox {
|
|
200
|
+
readonly box: TransformableBox;
|
|
201
|
+
constructor(box: TransformableBox);
|
|
202
|
+
apply(): void;
|
|
203
|
+
clear(): void;
|
|
314
204
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
205
|
+
declare class OverlayBox extends TransformableBox implements IDirection {
|
|
206
|
+
#private;
|
|
207
|
+
readonly element: HTMLElement;
|
|
208
|
+
constructor(element: HTMLElement);
|
|
209
|
+
get w(): number;
|
|
210
|
+
set w(value: number);
|
|
211
|
+
get h(): number;
|
|
212
|
+
set h(value: number);
|
|
213
|
+
get x(): number;
|
|
214
|
+
set x(value: number);
|
|
215
|
+
get y(): number;
|
|
216
|
+
set y(value: number);
|
|
217
|
+
/** The element's computed direction, read at call time. */
|
|
218
|
+
get direction(): "ltr" | "rtl";
|
|
219
|
+
dispose: () => void;
|
|
319
220
|
[Symbol.dispose](): void;
|
|
320
221
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
* I/O). This function is the wiring — it picks a pure `Session` from
|
|
340
|
-
* `detectEngagement` and adapts it to the recognizer through the io.
|
|
341
|
-
* The `resize` strategy (`freeResize` by default, or `detents`) decides the
|
|
342
|
-
* rested size, written to the public `--overlay-w`/`--overlay-h` channels;
|
|
343
|
-
* CSS renders and animates them. JS never touches `translate`/`top`/`left`.
|
|
344
|
-
*
|
|
345
|
-
* Registers its cleanup with the current scope (`onCleanup`) and also
|
|
346
|
-
* returns it as `dispose` / `Symbol.dispose`.
|
|
347
|
-
*
|
|
348
|
-
* @example
|
|
349
|
-
* ```ts
|
|
350
|
-
* import { constraint, createOverlayGestures, detents } from "elements-kit/ui/overlay";
|
|
351
|
-
*
|
|
352
|
-
* const el = document.querySelector("dialog.x-overlay")!;
|
|
353
|
-
* createOverlayGestures(el, { resize: detents(constraint(), [0.25, 0.6, 0.9]) });
|
|
354
|
-
* el.addEventListener("resizechange", (e) => console.log(e.detail));
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
declare function createOverlayGestures(overlay: HTMLElement, options?: OverlayGestureOptions): OverlayGestures;
|
|
222
|
+
interface Transformable {
|
|
223
|
+
displacement: Displacement;
|
|
224
|
+
}
|
|
225
|
+
declare namespace gestures_d_exports {
|
|
226
|
+
export { Modifier, detent, nearest, rubber, snap };
|
|
227
|
+
}
|
|
228
|
+
/** A pure display-time shaper: raw scalar → constrained scalar. */
|
|
229
|
+
type Modifier = (value: number) => number;
|
|
230
|
+
/** Elastic resistance past `[min, max]`. The true value stays in `Motion`, so
|
|
231
|
+
* release settles back cleanly. `dimension` = axis extent; `constant` = iOS
|
|
232
|
+
* tension (higher = looser). */
|
|
233
|
+
declare function rubber(min: number, max: number, dimension: number, constant?: number): Modifier;
|
|
234
|
+
/** The nearest detent to `value`. */
|
|
235
|
+
declare function nearest(value: number, points: number[]): number;
|
|
236
|
+
/** Magnetic pull toward the nearest detent during a drag (0 = free, 1 = snap). */
|
|
237
|
+
declare function detent(points: number[], strength?: number): Modifier;
|
|
238
|
+
/** Release target: project by velocity (`reach` ms of carry), then nearest detent. */
|
|
239
|
+
declare function snap(value: number, velocity: number, points: number[], reach?: number): number;
|
|
358
240
|
//#endregion
|
|
359
|
-
//#region src/ui/overlay/
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
241
|
+
//#region src/ui/overlay/motion.d.ts
|
|
242
|
+
interface IMotion {
|
|
243
|
+
value: number;
|
|
244
|
+
readonly displacement: number;
|
|
245
|
+
readonly delta: number;
|
|
246
|
+
readonly velocity: number;
|
|
247
|
+
abort(): void;
|
|
248
|
+
}
|
|
249
|
+
declare class Motion implements IMotion {
|
|
250
|
+
#private;
|
|
251
|
+
constructor(value?: number);
|
|
252
|
+
get value(): number;
|
|
253
|
+
set value(value: number);
|
|
254
|
+
get delta(): number;
|
|
255
|
+
get velocity(): number;
|
|
256
|
+
/** How far the value has moved from its initial (seed) — reactive.
|
|
257
|
+
* The displacement column: `value − initial`, starts at 0. */
|
|
258
|
+
get displacement(): number;
|
|
259
|
+
/** Nudge the value by a displacement — delta/velocity fall out of the setter. */
|
|
260
|
+
move(delta: number): void;
|
|
261
|
+
abort(initial?: number): void;
|
|
380
262
|
}
|
|
381
|
-
declare function resize(target: HTMLElement, space?: ResizeStrategy, ...effects: Effect[]): ResizeService;
|
|
382
263
|
//#endregion
|
|
383
|
-
export {
|
|
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 };
|