@svelte-lean/core 0.15.5 → 0.16.0
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 +43 -0
- package/dist/reorder.d.ts +57 -0
- package/dist/reorder.js +292 -0
- package/dist/reorder.js.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/runtime.js.map +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.js.map +1 -1
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# @svelte-lean/core
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8a774c6: The file drop covers what an upload field needs before the transport, on the native file input:
|
|
8
|
+
|
|
9
|
+
- **File list.** A `<ul data-slean-part="list">` in the root gets one item per file: a thumbnail
|
|
10
|
+
(`data-slean-preview`, an object URL released as soon as the image is decoded) or a type mark,
|
|
11
|
+
the name, the size in the page's language, and a remove button named by `data-slean-remove`
|
|
12
|
+
(`Remove {label}`). With a list, a new choice, drop or paste is added to the files already
|
|
13
|
+
listed. A remove button rewrites `input.files` (`DataTransfer`) and dispatches `input` and
|
|
14
|
+
`change`, so `bind:files`, `FormData` and a submit see the same files; focus moves to the next
|
|
15
|
+
remove button, else the input. A form reset clears the list.
|
|
16
|
+
- **Checks.** Every file the user brings is checked against `accept` (drops and pastes included,
|
|
17
|
+
which the picker's filter does not cover), `data-slean-maxsize` (bytes) and
|
|
18
|
+
`data-slean-maxcount`. A refused file leaves the input before `change` listeners read it, is
|
|
19
|
+
listed and announced with a message (`data-slean-typeerror`, `-sizeerror`, `-counterror`;
|
|
20
|
+
English defaults) and reported with the cancelable `slean:reject` event
|
|
21
|
+
(`{ behavior, rejected: { file, reason: 'type' | 'size' | 'count' }[] }`). States
|
|
22
|
+
`data-slean-rejected` and `data-slean-full`.
|
|
23
|
+
- **Area part.** `data-slean-part="area"` around the input is the drop area when the root holds
|
|
24
|
+
more than the area; without it the root is the area, as before. An empty `icon` part in it draws
|
|
25
|
+
the upload icon.
|
|
26
|
+
- **Paste.** An image pasted while the input has focus is added like a dropped file (Chromium and
|
|
27
|
+
Firefox dispatch `paste` there). `@svelte-lean/core` routes `paste` as a shared event type.
|
|
28
|
+
- **Helpers.** `setFileDropFiles(root, files)`, `fileDropItem(root, file)` (the item to mark
|
|
29
|
+
`aria-busy` and give a `<progress>` during an upload), `fileSize(bytes, lang)`.
|
|
30
|
+
- **Styles.** `file-drop.css` draws the rows, refused rows in the error color, and the
|
|
31
|
+
`data-variant="picture-card"` and `"picture-circle"` tiles (Ant Design's list types), the area
|
|
32
|
+
being the last tile, hidden at the file limit. New tokens `--slean-file-drop-tile-size`,
|
|
33
|
+
`--slean-icon-file`, `--slean-icon-upload`.
|
|
34
|
+
|
|
35
|
+
The file-drop register module grows from 1326 B to 2983 B brotli (budget 3300 B). A Content
|
|
36
|
+
Security Policy needs `img-src blob:` for the thumbnails.
|
|
37
|
+
- 12ca0ce: A new subpath, `@svelte-lean/core/reorder` (ADR 0012): `reorder(options)`, the live drag engine of
|
|
38
|
+
`<DataTable onRowMove>` moved out of the table and shared with the sortable primitive. One press:
|
|
39
|
+
the item lifts after 3 px, every item's box is read once, transforms only while the pointer moves,
|
|
40
|
+
auto-scroll near the scrolling container's edge, Escape and `pointercancel` cancel, and the drop
|
|
41
|
+
glides into the place the caller's update gave it; all listeners under one `AbortController`. It
|
|
42
|
+
takes an `axis` (`x` for a row, right-to-left rows detected), the caller's attribute names, a
|
|
43
|
+
`block` of elements moving together and a `drop` that may refuse the move. The kernel entry does
|
|
44
|
+
not import it (its budget is unchanged); the subpath has its own, 1950 B gzip (measured 1752 B).
|
|
45
|
+
|
|
3
46
|
## 0.15.5
|
|
4
47
|
|
|
5
48
|
No changes in this release.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** The attributes the engine writes while a drag runs. */
|
|
2
|
+
export interface ReorderAttributes {
|
|
3
|
+
/** On the root from lift until the drop has settled. */
|
|
4
|
+
dragging: string;
|
|
5
|
+
/** On the root for the one frame in which settled positions are written without transitions. */
|
|
6
|
+
settling: string;
|
|
7
|
+
/** On the elements of the lifted item. */
|
|
8
|
+
lifted: string;
|
|
9
|
+
}
|
|
10
|
+
/** A drop at another place. */
|
|
11
|
+
export interface ReorderMove {
|
|
12
|
+
/** Key of the dragged item. */
|
|
13
|
+
source: string;
|
|
14
|
+
/** Key of the item whose place it takes. */
|
|
15
|
+
target: string;
|
|
16
|
+
/** Index of the dragged item in `items()` at lift. */
|
|
17
|
+
from: number;
|
|
18
|
+
/** Index of the place it was dropped on, in the same list. */
|
|
19
|
+
to: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ReorderOptions {
|
|
22
|
+
/** The `pointerdown` on a handle. */
|
|
23
|
+
event: PointerEvent;
|
|
24
|
+
/** The handle: it captures the pointer for the drag. */
|
|
25
|
+
handle: HTMLElement;
|
|
26
|
+
/** The item the handle moves (the first element of its block). */
|
|
27
|
+
item: HTMLElement;
|
|
28
|
+
/** Receives the `dragging` and `settling` attributes. */
|
|
29
|
+
root: HTMLElement;
|
|
30
|
+
/** The items, in document order. Read at lift and again after `update`. */
|
|
31
|
+
items: () => HTMLElement[];
|
|
32
|
+
/** The identity of an item, stable across a re-render (a key, a value). */
|
|
33
|
+
key: (item: HTMLElement) => string;
|
|
34
|
+
/** The elements that move with an item (a table row and its detail rows); `[item]` by default. */
|
|
35
|
+
block?: (item: HTMLElement) => HTMLElement[];
|
|
36
|
+
/** `y` (the default) for a column of items, `x` for a row; a row flowing right to left is detected. */
|
|
37
|
+
axis?: 'x' | 'y';
|
|
38
|
+
/** Where the search for the scrolling container starts; the root by default. */
|
|
39
|
+
viewport?: HTMLElement;
|
|
40
|
+
/** The attribute names the caller's stylesheet reads. */
|
|
41
|
+
attributes: ReorderAttributes;
|
|
42
|
+
/**
|
|
43
|
+
* Reports a drop on another place. Return `false` when the move is refused: every item slides
|
|
44
|
+
* back and `update` is not awaited.
|
|
45
|
+
*/
|
|
46
|
+
drop: (move: ReorderMove) => boolean | void;
|
|
47
|
+
/** Resolves once the answer to `drop` is in the document (Svelte's `tick`, a frame). */
|
|
48
|
+
update: () => Promise<void>;
|
|
49
|
+
/** Called once, when the press ends and its listeners are gone: a drop, a cancel or a click. */
|
|
50
|
+
end?: () => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Starts the drag of `item` from a `pointerdown` on its handle. Returns false, having done
|
|
54
|
+
* nothing, for a press that cannot drag (not the primary button or pointer); true when the press
|
|
55
|
+
* holds its listeners until `end`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function reorder(options: ReorderOptions): boolean;
|
package/dist/reorder.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The live reorder engine (`@svelte-lean/core/reorder`, ADR 0012): one pointer drag of an item
|
|
3
|
+
* through a list, shared by `<DataTable />`'s row drag (`onRowMove`) and the sortable primitive.
|
|
4
|
+
* DOM only: nothing is moved while the pointer moves; transforms are written straight to the
|
|
5
|
+
* elements, and only when they change.
|
|
6
|
+
*
|
|
7
|
+
* A press on a handle lifts its item after `ACTIVATION` pixels: every item's box is read once,
|
|
8
|
+
* then the lifted item follows the pointer and the items between its place and the place under
|
|
9
|
+
* it slide out of its way, so the drop position is visible before release. Release reports the
|
|
10
|
+
* move (`drop`), waits for the answer (`update`) and lets the item glide from where it was dropped
|
|
11
|
+
* into the place it now has. A cancel (Escape, `pointercancel`, a lost capture), a refused drop or
|
|
12
|
+
* a move nobody made slides every item back. Near the visible edge of the scrolling container the
|
|
13
|
+
* container scrolls, on a timer (a hidden tab runs no animation frames).
|
|
14
|
+
*
|
|
15
|
+
* Every listener exists only for the length of one press and is removed through one
|
|
16
|
+
* `AbortController`. Nothing here runs at module evaluation, and the runtime kernel
|
|
17
|
+
* (`@svelte-lean/core`) never imports this module.
|
|
18
|
+
*/
|
|
19
|
+
const ACTIVATION = 3;
|
|
20
|
+
const EDGE = 48;
|
|
21
|
+
const SPEED = 20;
|
|
22
|
+
const INTERVAL = 16;
|
|
23
|
+
/** The slide of the items (the stylesheets), and a little more, before the end state is cleaned up. */
|
|
24
|
+
const SETTLE_MS = 200;
|
|
25
|
+
/** The cleanup of a drop still sliding into place, per root: a new press runs it first. */
|
|
26
|
+
const finishing = new WeakMap();
|
|
27
|
+
/**
|
|
28
|
+
* Starts the drag of `item` from a `pointerdown` on its handle. Returns false, having done
|
|
29
|
+
* nothing, for a press that cannot drag (not the primary button or pointer); true when the press
|
|
30
|
+
* holds its listeners until `end`.
|
|
31
|
+
*/
|
|
32
|
+
export function reorder(options) {
|
|
33
|
+
const { event, handle, root, attributes: names } = options;
|
|
34
|
+
if (event.button !== 0 || !event.isPrimary)
|
|
35
|
+
return false;
|
|
36
|
+
finishing.get(root)?.();
|
|
37
|
+
const doc = handle.ownerDocument;
|
|
38
|
+
const x = options.axis === 'x';
|
|
39
|
+
const START = x ? 'left' : 'top';
|
|
40
|
+
const END = x ? 'right' : 'bottom';
|
|
41
|
+
const SCROLL = x ? 'scrollLeft' : 'scrollTop';
|
|
42
|
+
const POINTER = x ? 'clientX' : 'clientY';
|
|
43
|
+
const blockOf = options.block ?? ((item) => [item]);
|
|
44
|
+
const controller = new AbortController();
|
|
45
|
+
const { signal } = controller;
|
|
46
|
+
let pointer = event[POINTER];
|
|
47
|
+
let blocks = [];
|
|
48
|
+
let dragged;
|
|
49
|
+
let from = -1;
|
|
50
|
+
let target = -1;
|
|
51
|
+
/** 1, or -1 for a row of items flowing right to left. */
|
|
52
|
+
let sign = 1;
|
|
53
|
+
/** The distance between the starts of the dragged item and its neighbour: its size and the gap. */
|
|
54
|
+
let step = 0;
|
|
55
|
+
let scroller = doc.documentElement;
|
|
56
|
+
let page = false;
|
|
57
|
+
let scrollStart = 0;
|
|
58
|
+
let written = 0;
|
|
59
|
+
let timer;
|
|
60
|
+
let ended = false;
|
|
61
|
+
try {
|
|
62
|
+
handle.setPointerCapture(event.pointerId);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// No capture (an engine or a test environment without it): the document listeners below
|
|
66
|
+
// still receive the moves while the pointer stays over the page.
|
|
67
|
+
}
|
|
68
|
+
const translate = (elements, value) => {
|
|
69
|
+
const v = sign * value;
|
|
70
|
+
for (const element of elements)
|
|
71
|
+
element.style.transform = v ? `translate${x ? 'X' : 'Y'}(${v}px)` : '';
|
|
72
|
+
};
|
|
73
|
+
/** Where an element starts and ends along the axis now, in the direction the items flow. */
|
|
74
|
+
const span = (element) => {
|
|
75
|
+
const box = element.getBoundingClientRect();
|
|
76
|
+
const a = sign * box[START];
|
|
77
|
+
const b = sign * box[END];
|
|
78
|
+
return a < b ? [a, b] : [b, a];
|
|
79
|
+
};
|
|
80
|
+
/** The nearest container above the viewport that scrolls on the axis; the document otherwise. */
|
|
81
|
+
function scrollerOf() {
|
|
82
|
+
for (let element = options.viewport ?? root; element && element !== doc.body && element !== doc.documentElement; element = element.parentElement) {
|
|
83
|
+
if ((x
|
|
84
|
+
? element.scrollWidth > element.clientWidth + 1
|
|
85
|
+
: element.scrollHeight > element.clientHeight + 1) &&
|
|
86
|
+
/auto|scroll|overlay/.test(getComputedStyle(element)[x ? 'overflowX' : 'overflowY']))
|
|
87
|
+
return element;
|
|
88
|
+
}
|
|
89
|
+
return doc.scrollingElement ?? doc.documentElement;
|
|
90
|
+
}
|
|
91
|
+
function lift() {
|
|
92
|
+
const items = options.items();
|
|
93
|
+
const last = items.length - 1;
|
|
94
|
+
if (x &&
|
|
95
|
+
last > 0 &&
|
|
96
|
+
items[last].getBoundingClientRect().left < items[0].getBoundingClientRect().left)
|
|
97
|
+
sign = -1;
|
|
98
|
+
blocks = items.map((item) => {
|
|
99
|
+
const elements = blockOf(item);
|
|
100
|
+
const [start] = span(elements[0]);
|
|
101
|
+
const end = span(elements[elements.length - 1])[1];
|
|
102
|
+
return { key: options.key(item), elements, start, size: end - start, shift: 0 };
|
|
103
|
+
});
|
|
104
|
+
from = target = items.indexOf(options.item);
|
|
105
|
+
dragged = blocks[from];
|
|
106
|
+
if (!dragged)
|
|
107
|
+
return false;
|
|
108
|
+
const next = blocks[from + 1];
|
|
109
|
+
const previous = blocks[from - 1];
|
|
110
|
+
step = next
|
|
111
|
+
? next.start - dragged.start
|
|
112
|
+
: previous
|
|
113
|
+
? dragged.start + dragged.size - previous.start - previous.size
|
|
114
|
+
: dragged.size;
|
|
115
|
+
scroller = scrollerOf();
|
|
116
|
+
page = scroller === doc.scrollingElement || scroller === doc.documentElement;
|
|
117
|
+
scrollStart = scroller[SCROLL];
|
|
118
|
+
root.setAttribute(names.dragging, '');
|
|
119
|
+
for (const element of dragged.elements) {
|
|
120
|
+
element.setAttribute(names.lifted, '');
|
|
121
|
+
// The lifted item follows the pointer exactly; the others slide (the stylesheets).
|
|
122
|
+
element.style.transition = 'none';
|
|
123
|
+
}
|
|
124
|
+
doc.addEventListener('keydown', escape, { signal, capture: true });
|
|
125
|
+
(page ? doc : scroller).addEventListener('scroll', frame, { signal, passive: true });
|
|
126
|
+
timer = setInterval(autoScroll, INTERVAL);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
function frame() {
|
|
130
|
+
if (!dragged)
|
|
131
|
+
return;
|
|
132
|
+
const moved = sign * (pointer - event[POINTER] + scroller[SCROLL] - scrollStart);
|
|
133
|
+
if (moved !== written) {
|
|
134
|
+
written = moved;
|
|
135
|
+
translate(dragged.elements, moved);
|
|
136
|
+
}
|
|
137
|
+
const centre = dragged.start + moved + dragged.size / 2;
|
|
138
|
+
const middle = (block) => block.start + block.size / 2;
|
|
139
|
+
let next = from;
|
|
140
|
+
while (next + 1 < blocks.length && centre > middle(blocks[next + 1]))
|
|
141
|
+
next++;
|
|
142
|
+
if (next === from)
|
|
143
|
+
while (next > 0 && centre < middle(blocks[next - 1]))
|
|
144
|
+
next--;
|
|
145
|
+
target = next;
|
|
146
|
+
blocks.forEach((block, i) => {
|
|
147
|
+
if (i === from)
|
|
148
|
+
return;
|
|
149
|
+
const shift = i > from && i <= next ? -step : i < from && i >= next ? step : 0;
|
|
150
|
+
if (shift === block.shift)
|
|
151
|
+
return;
|
|
152
|
+
block.shift = shift;
|
|
153
|
+
translate(block.elements, shift);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** Scrolls while the pointer is within `EDGE` of the container's visible edges on the axis. */
|
|
157
|
+
function autoScroll() {
|
|
158
|
+
const view = doc.documentElement[x ? 'clientWidth' : 'clientHeight'];
|
|
159
|
+
const box = page ? null : scroller.getBoundingClientRect();
|
|
160
|
+
const low = Math.max(box ? box[START] : 0, 0);
|
|
161
|
+
const high = Math.min(box ? box[END] : view, view);
|
|
162
|
+
const speed = (distance) => Math.ceil(SPEED * (1 - Math.max(0, distance) / EDGE));
|
|
163
|
+
const delta = pointer - low < EDGE
|
|
164
|
+
? -speed(pointer - low)
|
|
165
|
+
: high - pointer < EDGE
|
|
166
|
+
? speed(high - pointer)
|
|
167
|
+
: 0;
|
|
168
|
+
if (!delta)
|
|
169
|
+
return;
|
|
170
|
+
const before = scroller[SCROLL];
|
|
171
|
+
scroller[SCROLL] = before + delta;
|
|
172
|
+
if (scroller[SCROLL] !== before)
|
|
173
|
+
frame();
|
|
174
|
+
}
|
|
175
|
+
function stop() {
|
|
176
|
+
controller.abort();
|
|
177
|
+
clearInterval(timer);
|
|
178
|
+
if (!ended)
|
|
179
|
+
options.end?.();
|
|
180
|
+
ended = true;
|
|
181
|
+
}
|
|
182
|
+
/** Leaves the elements as they are now, after the slide back or into place. */
|
|
183
|
+
function later(elements) {
|
|
184
|
+
const done = () => {
|
|
185
|
+
clearTimeout(timeout);
|
|
186
|
+
finishing.delete(root);
|
|
187
|
+
for (const element of elements) {
|
|
188
|
+
element.removeAttribute(names.lifted);
|
|
189
|
+
element.style.transform = '';
|
|
190
|
+
element.style.transition = '';
|
|
191
|
+
}
|
|
192
|
+
root.removeAttribute(names.settling);
|
|
193
|
+
root.removeAttribute(names.dragging);
|
|
194
|
+
};
|
|
195
|
+
const timeout = setTimeout(done, SETTLE_MS);
|
|
196
|
+
finishing.set(root, done);
|
|
197
|
+
}
|
|
198
|
+
/** Every item slides back to its place. */
|
|
199
|
+
function back() {
|
|
200
|
+
for (const element of dragged.elements)
|
|
201
|
+
element.style.transition = '';
|
|
202
|
+
for (const block of blocks) {
|
|
203
|
+
block.shift = 0;
|
|
204
|
+
translate(block.elements, 0);
|
|
205
|
+
}
|
|
206
|
+
later(blocks.flatMap((block) => block.elements));
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The move has been answered. Positions are reset with transitions off; the dragged item
|
|
210
|
+
* (perhaps a new element: it is found again by its key) starts where it was dropped and
|
|
211
|
+
* slides into its new place.
|
|
212
|
+
*/
|
|
213
|
+
function settle(dropped) {
|
|
214
|
+
const key = dragged.key;
|
|
215
|
+
const now = options.items();
|
|
216
|
+
const item = now.find((element) => options.key(element) === key);
|
|
217
|
+
if (item && now.indexOf(item) === from)
|
|
218
|
+
return back();
|
|
219
|
+
root.setAttribute(names.settling, '');
|
|
220
|
+
for (const block of blocks)
|
|
221
|
+
for (const element of block.elements) {
|
|
222
|
+
element.removeAttribute(names.lifted);
|
|
223
|
+
element.style.transform = '';
|
|
224
|
+
element.style.transition = '';
|
|
225
|
+
}
|
|
226
|
+
if (!item)
|
|
227
|
+
return later([]);
|
|
228
|
+
const elements = blockOf(item);
|
|
229
|
+
for (const element of elements)
|
|
230
|
+
element.setAttribute(names.lifted, '');
|
|
231
|
+
translate(elements, dropped - span(item)[0]);
|
|
232
|
+
void item.offsetHeight;
|
|
233
|
+
root.removeAttribute(names.settling);
|
|
234
|
+
translate(elements, 0);
|
|
235
|
+
later(elements);
|
|
236
|
+
}
|
|
237
|
+
function drop() {
|
|
238
|
+
stop();
|
|
239
|
+
if (target === from)
|
|
240
|
+
return back();
|
|
241
|
+
const dropped = span(dragged.elements[0])[0];
|
|
242
|
+
const answer = options.drop({
|
|
243
|
+
source: dragged.key,
|
|
244
|
+
target: blocks[target].key,
|
|
245
|
+
from,
|
|
246
|
+
to: target
|
|
247
|
+
});
|
|
248
|
+
if (answer === false)
|
|
249
|
+
return back();
|
|
250
|
+
void options.update().then(() => settle(dropped));
|
|
251
|
+
}
|
|
252
|
+
function cancel() {
|
|
253
|
+
stop();
|
|
254
|
+
if (dragged)
|
|
255
|
+
back();
|
|
256
|
+
}
|
|
257
|
+
function escape(e) {
|
|
258
|
+
if (e.key !== 'Escape')
|
|
259
|
+
return;
|
|
260
|
+
e.preventDefault();
|
|
261
|
+
e.stopPropagation();
|
|
262
|
+
cancel();
|
|
263
|
+
}
|
|
264
|
+
doc.addEventListener('pointermove', (e) => {
|
|
265
|
+
if (e.pointerId !== event.pointerId)
|
|
266
|
+
return;
|
|
267
|
+
pointer = e[POINTER];
|
|
268
|
+
if (!dragged) {
|
|
269
|
+
if (Math.hypot(e.clientX - event.clientX, e.clientY - event.clientY) < ACTIVATION)
|
|
270
|
+
return;
|
|
271
|
+
if (!lift())
|
|
272
|
+
return stop();
|
|
273
|
+
}
|
|
274
|
+
e.preventDefault();
|
|
275
|
+
frame();
|
|
276
|
+
}, { signal });
|
|
277
|
+
doc.addEventListener('pointerup', (e) => {
|
|
278
|
+
if (e.pointerId !== event.pointerId)
|
|
279
|
+
return;
|
|
280
|
+
if (dragged)
|
|
281
|
+
drop();
|
|
282
|
+
else
|
|
283
|
+
stop();
|
|
284
|
+
}, { signal });
|
|
285
|
+
doc.addEventListener('pointercancel', (e) => {
|
|
286
|
+
if (e.pointerId === event.pointerId)
|
|
287
|
+
cancel();
|
|
288
|
+
}, { signal });
|
|
289
|
+
handle.addEventListener('lostpointercapture', cancel, { signal });
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=reorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reorder.js","sourceRoot":"","sources":["../src/reorder.ts"],"names":[],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,EAAE,EAAE;QACL,IAAI,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS;YAAE,OAAO;QAC5C,IAAI,OAAO;YAAE,IAAI,EAAE,CAAC;;YACf,IAAI,EAAE,CAAC;IACb,CAAC,EACD,EAAE,MAAM,EAAE,CACV,CAAC;IACF,GAAG,CAAC,gBAAgB,CACnB,eAAe,EACf,CAAC,CAAC,EAAE,EAAE;QACL,IAAI,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS;YAAE,MAAM,EAAE,CAAC;IAC/C,CAAC,EACD,EAAE,MAAM,EAAE,CACV,CAAC;IACF,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAClE,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * The live reorder engine (`@svelte-lean/core/reorder`, ADR 0012): one pointer drag of an item\n * through a list, shared by `<DataTable />`'s row drag (`onRowMove`) and the sortable primitive.\n * DOM only: nothing is moved while the pointer moves; transforms are written straight to the\n * elements, and only when they change.\n *\n * A press on a handle lifts its item after `ACTIVATION` pixels: every item's box is read once,\n * then the lifted item follows the pointer and the items between its place and the place under\n * it slide out of its way, so the drop position is visible before release. Release reports the\n * move (`drop`), waits for the answer (`update`) and lets the item glide from where it was dropped\n * into the place it now has. A cancel (Escape, `pointercancel`, a lost capture), a refused drop or\n * a move nobody made slides every item back. Near the visible edge of the scrolling container the\n * container scrolls, on a timer (a hidden tab runs no animation frames).\n *\n * Every listener exists only for the length of one press and is removed through one\n * `AbortController`. Nothing here runs at module evaluation, and the runtime kernel\n * (`@svelte-lean/core`) never imports this module.\n */\nconst ACTIVATION = 3;\nconst EDGE = 48;\nconst SPEED = 20;\nconst INTERVAL = 16;\n/** The slide of the items (the stylesheets), and a little more, before the end state is cleaned up. */\nconst SETTLE_MS = 200;\n\n/** The attributes the engine writes while a drag runs. */\nexport interface ReorderAttributes {\n\t/** On the root from lift until the drop has settled. */\n\tdragging: string;\n\t/** On the root for the one frame in which settled positions are written without transitions. */\n\tsettling: string;\n\t/** On the elements of the lifted item. */\n\tlifted: string;\n}\n\n/** A drop at another place. */\nexport interface ReorderMove {\n\t/** Key of the dragged item. */\n\tsource: string;\n\t/** Key of the item whose place it takes. */\n\ttarget: string;\n\t/** Index of the dragged item in `items()` at lift. */\n\tfrom: number;\n\t/** Index of the place it was dropped on, in the same list. */\n\tto: number;\n}\n\nexport interface ReorderOptions {\n\t/** The `pointerdown` on a handle. */\n\tevent: PointerEvent;\n\t/** The handle: it captures the pointer for the drag. */\n\thandle: HTMLElement;\n\t/** The item the handle moves (the first element of its block). */\n\titem: HTMLElement;\n\t/** Receives the `dragging` and `settling` attributes. */\n\troot: HTMLElement;\n\t/** The items, in document order. Read at lift and again after `update`. */\n\titems: () => HTMLElement[];\n\t/** The identity of an item, stable across a re-render (a key, a value). */\n\tkey: (item: HTMLElement) => string;\n\t/** The elements that move with an item (a table row and its detail rows); `[item]` by default. */\n\tblock?: (item: HTMLElement) => HTMLElement[];\n\t/** `y` (the default) for a column of items, `x` for a row; a row flowing right to left is detected. */\n\taxis?: 'x' | 'y';\n\t/** Where the search for the scrolling container starts; the root by default. */\n\tviewport?: HTMLElement;\n\t/** The attribute names the caller's stylesheet reads. */\n\tattributes: ReorderAttributes;\n\t/**\n\t * Reports a drop on another place. Return `false` when the move is refused: every item slides\n\t * back and `update` is not awaited.\n\t */\n\tdrop: (move: ReorderMove) => boolean | void;\n\t/** Resolves once the answer to `drop` is in the document (Svelte's `tick`, a frame). */\n\tupdate: () => Promise<void>;\n\t/** Called once, when the press ends and its listeners are gone: a drop, a cancel or a click. */\n\tend?: () => void;\n}\n\n/** An item and the elements that follow it, measured at lift along the axis. */\ninterface Block {\n\tkey: string;\n\telements: HTMLElement[];\n\t/** Start along the axis, in the direction the items flow. */\n\tstart: number;\n\tsize: number;\n\tshift: number;\n}\n\n/** The cleanup of a drop still sliding into place, per root: a new press runs it first. */\nconst finishing = new WeakMap<HTMLElement, () => void>();\n\n/**\n * Starts the drag of `item` from a `pointerdown` on its handle. Returns false, having done\n * nothing, for a press that cannot drag (not the primary button or pointer); true when the press\n * holds its listeners until `end`.\n */\nexport function reorder(options: ReorderOptions): boolean {\n\tconst { event, handle, root, attributes: names } = options;\n\tif (event.button !== 0 || !event.isPrimary) return false;\n\tfinishing.get(root)?.();\n\tconst doc = handle.ownerDocument;\n\tconst x = options.axis === 'x';\n\tconst START = x ? 'left' : 'top';\n\tconst END = x ? 'right' : 'bottom';\n\tconst SCROLL = x ? 'scrollLeft' : 'scrollTop';\n\tconst POINTER = x ? 'clientX' : 'clientY';\n\tconst blockOf = options.block ?? ((item: HTMLElement) => [item]);\n\tconst controller = new AbortController();\n\tconst { signal } = controller;\n\tlet pointer = event[POINTER];\n\tlet blocks: Block[] = [];\n\tlet dragged: Block | undefined;\n\tlet from = -1;\n\tlet target = -1;\n\t/** 1, or -1 for a row of items flowing right to left. */\n\tlet sign = 1;\n\t/** The distance between the starts of the dragged item and its neighbour: its size and the gap. */\n\tlet step = 0;\n\tlet scroller: Element = doc.documentElement;\n\tlet page = false;\n\tlet scrollStart = 0;\n\tlet written = 0;\n\tlet timer: ReturnType<typeof setInterval> | undefined;\n\tlet ended = false;\n\n\ttry {\n\t\thandle.setPointerCapture(event.pointerId);\n\t} catch {\n\t\t// No capture (an engine or a test environment without it): the document listeners below\n\t\t// still receive the moves while the pointer stays over the page.\n\t}\n\n\tconst translate = (elements: HTMLElement[], value: number) => {\n\t\tconst v = sign * value;\n\t\tfor (const element of elements)\n\t\t\telement.style.transform = v ? `translate${x ? 'X' : 'Y'}(${v}px)` : '';\n\t};\n\t/** Where an element starts and ends along the axis now, in the direction the items flow. */\n\tconst span = (element: Element): [number, number] => {\n\t\tconst box = element.getBoundingClientRect();\n\t\tconst a = sign * box[START];\n\t\tconst b = sign * box[END];\n\t\treturn a < b ? [a, b] : [b, a];\n\t};\n\n\t/** The nearest container above the viewport that scrolls on the axis; the document otherwise. */\n\tfunction scrollerOf(): Element {\n\t\tfor (\n\t\t\tlet element: HTMLElement | null = options.viewport ?? root;\n\t\t\telement && element !== doc.body && element !== doc.documentElement;\n\t\t\telement = element.parentElement\n\t\t) {\n\t\t\tif (\n\t\t\t\t(x\n\t\t\t\t\t? element.scrollWidth > element.clientWidth + 1\n\t\t\t\t\t: element.scrollHeight > element.clientHeight + 1) &&\n\t\t\t\t/auto|scroll|overlay/.test(getComputedStyle(element)[x ? 'overflowX' : 'overflowY'])\n\t\t\t)\n\t\t\t\treturn element;\n\t\t}\n\t\treturn doc.scrollingElement ?? doc.documentElement;\n\t}\n\n\tfunction lift(): boolean {\n\t\tconst items = options.items();\n\t\tconst last = items.length - 1;\n\t\tif (\n\t\t\tx &&\n\t\t\tlast > 0 &&\n\t\t\titems[last]!.getBoundingClientRect().left < items[0]!.getBoundingClientRect().left\n\t\t)\n\t\t\tsign = -1;\n\t\tblocks = items.map((item) => {\n\t\t\tconst elements = blockOf(item);\n\t\t\tconst [start] = span(elements[0]!);\n\t\t\tconst end = span(elements[elements.length - 1]!)[1];\n\t\t\treturn { key: options.key(item), elements, start, size: end - start, shift: 0 };\n\t\t});\n\t\tfrom = target = items.indexOf(options.item);\n\t\tdragged = blocks[from];\n\t\tif (!dragged) return false;\n\t\tconst next = blocks[from + 1];\n\t\tconst previous = blocks[from - 1];\n\t\tstep = next\n\t\t\t? next.start - dragged.start\n\t\t\t: previous\n\t\t\t\t? dragged.start + dragged.size - previous.start - previous.size\n\t\t\t\t: dragged.size;\n\t\tscroller = scrollerOf();\n\t\tpage = scroller === doc.scrollingElement || scroller === doc.documentElement;\n\t\tscrollStart = scroller[SCROLL];\n\t\troot.setAttribute(names.dragging, '');\n\t\tfor (const element of dragged.elements) {\n\t\t\telement.setAttribute(names.lifted, '');\n\t\t\t// The lifted item follows the pointer exactly; the others slide (the stylesheets).\n\t\t\telement.style.transition = 'none';\n\t\t}\n\t\tdoc.addEventListener('keydown', escape, { signal, capture: true });\n\t\t(page ? doc : scroller).addEventListener('scroll', frame, { signal, passive: true });\n\t\ttimer = setInterval(autoScroll, INTERVAL);\n\t\treturn true;\n\t}\n\n\tfunction frame() {\n\t\tif (!dragged) return;\n\t\tconst moved = sign * (pointer - event[POINTER] + scroller[SCROLL] - scrollStart);\n\t\tif (moved !== written) {\n\t\t\twritten = moved;\n\t\t\ttranslate(dragged.elements, moved);\n\t\t}\n\t\tconst centre = dragged.start + moved + dragged.size / 2;\n\t\tconst middle = (block: Block) => block.start + block.size / 2;\n\t\tlet next = from;\n\t\twhile (next + 1 < blocks.length && centre > middle(blocks[next + 1]!)) next++;\n\t\tif (next === from) while (next > 0 && centre < middle(blocks[next - 1]!)) next--;\n\t\ttarget = next;\n\t\tblocks.forEach((block, i) => {\n\t\t\tif (i === from) return;\n\t\t\tconst shift = i > from && i <= next ? -step : i < from && i >= next ? step : 0;\n\t\t\tif (shift === block.shift) return;\n\t\t\tblock.shift = shift;\n\t\t\ttranslate(block.elements, shift);\n\t\t});\n\t}\n\n\t/** Scrolls while the pointer is within `EDGE` of the container's visible edges on the axis. */\n\tfunction autoScroll() {\n\t\tconst view = doc.documentElement[x ? 'clientWidth' : 'clientHeight'];\n\t\tconst box = page ? null : scroller.getBoundingClientRect();\n\t\tconst low = Math.max(box ? box[START] : 0, 0);\n\t\tconst high = Math.min(box ? box[END] : view, view);\n\t\tconst speed = (distance: number) => Math.ceil(SPEED * (1 - Math.max(0, distance) / EDGE));\n\t\tconst delta =\n\t\t\tpointer - low < EDGE\n\t\t\t\t? -speed(pointer - low)\n\t\t\t\t: high - pointer < EDGE\n\t\t\t\t\t? speed(high - pointer)\n\t\t\t\t\t: 0;\n\t\tif (!delta) return;\n\t\tconst before = scroller[SCROLL];\n\t\tscroller[SCROLL] = before + delta;\n\t\tif (scroller[SCROLL] !== before) frame();\n\t}\n\n\tfunction stop() {\n\t\tcontroller.abort();\n\t\tclearInterval(timer);\n\t\tif (!ended) options.end?.();\n\t\tended = true;\n\t}\n\n\t/** Leaves the elements as they are now, after the slide back or into place. */\n\tfunction later(elements: HTMLElement[]) {\n\t\tconst done = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tfinishing.delete(root);\n\t\t\tfor (const element of elements) {\n\t\t\t\telement.removeAttribute(names.lifted);\n\t\t\t\telement.style.transform = '';\n\t\t\t\telement.style.transition = '';\n\t\t\t}\n\t\t\troot.removeAttribute(names.settling);\n\t\t\troot.removeAttribute(names.dragging);\n\t\t};\n\t\tconst timeout = setTimeout(done, SETTLE_MS);\n\t\tfinishing.set(root, done);\n\t}\n\n\t/** Every item slides back to its place. */\n\tfunction back() {\n\t\tfor (const element of dragged!.elements) element.style.transition = '';\n\t\tfor (const block of blocks) {\n\t\t\tblock.shift = 0;\n\t\t\ttranslate(block.elements, 0);\n\t\t}\n\t\tlater(blocks.flatMap((block) => block.elements));\n\t}\n\n\t/**\n\t * The move has been answered. Positions are reset with transitions off; the dragged item\n\t * (perhaps a new element: it is found again by its key) starts where it was dropped and\n\t * slides into its new place.\n\t */\n\tfunction settle(dropped: number) {\n\t\tconst key = dragged!.key;\n\t\tconst now = options.items();\n\t\tconst item = now.find((element) => options.key(element) === key);\n\t\tif (item && now.indexOf(item) === from) return back();\n\t\troot.setAttribute(names.settling, '');\n\t\tfor (const block of blocks)\n\t\t\tfor (const element of block.elements) {\n\t\t\t\telement.removeAttribute(names.lifted);\n\t\t\t\telement.style.transform = '';\n\t\t\t\telement.style.transition = '';\n\t\t\t}\n\t\tif (!item) return later([]);\n\t\tconst elements = blockOf(item);\n\t\tfor (const element of elements) element.setAttribute(names.lifted, '');\n\t\ttranslate(elements, dropped - span(item)[0]);\n\t\tvoid item.offsetHeight;\n\t\troot.removeAttribute(names.settling);\n\t\ttranslate(elements, 0);\n\t\tlater(elements);\n\t}\n\n\tfunction drop() {\n\t\tstop();\n\t\tif (target === from) return back();\n\t\tconst dropped = span(dragged!.elements[0]!)[0];\n\t\tconst answer = options.drop({\n\t\t\tsource: dragged!.key,\n\t\t\ttarget: blocks[target]!.key,\n\t\t\tfrom,\n\t\t\tto: target\n\t\t});\n\t\tif (answer === false) return back();\n\t\tvoid options.update().then(() => settle(dropped));\n\t}\n\n\tfunction cancel() {\n\t\tstop();\n\t\tif (dragged) back();\n\t}\n\n\tfunction escape(e: KeyboardEvent) {\n\t\tif (e.key !== 'Escape') return;\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t\tcancel();\n\t}\n\n\tdoc.addEventListener(\n\t\t'pointermove',\n\t\t(e) => {\n\t\t\tif (e.pointerId !== event.pointerId) return;\n\t\t\tpointer = e[POINTER];\n\t\t\tif (!dragged) {\n\t\t\t\tif (Math.hypot(e.clientX - event.clientX, e.clientY - event.clientY) < ACTIVATION) return;\n\t\t\t\tif (!lift()) return stop();\n\t\t\t}\n\t\t\te.preventDefault();\n\t\t\tframe();\n\t\t},\n\t\t{ signal }\n\t);\n\tdoc.addEventListener(\n\t\t'pointerup',\n\t\t(e) => {\n\t\t\tif (e.pointerId !== event.pointerId) return;\n\t\t\tif (dragged) drop();\n\t\t\telse stop();\n\t\t},\n\t\t{ signal }\n\t);\n\tdoc.addEventListener(\n\t\t'pointercancel',\n\t\t(e) => {\n\t\t\tif (e.pointerId === event.pointerId) cancel();\n\t\t},\n\t\t{ signal }\n\t);\n\thandle.addEventListener('lostpointercapture', cancel, { signal });\n\treturn true;\n}\n"]}
|
package/dist/runtime.js
CHANGED
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EACN,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,IAAI,EACJ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAA8B;I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GAAG,GAA2B,EAAE,CAAC;YACvC,KAAK,MAAM,IAAI,IAAI,SAAS;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5C,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,OAAO;YACN,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,EAAE,CAAC;YACP,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB,SAAS,EAAE,EAAE,CAAC;QACf,CAAC;KACD,CAAC;IACF,YAAY,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import type {\n\tBehaviorDefinition,\n\tBehaviorHandler,\n\tRuntime,\n\tRuntimeOptions,\n\tRuntimeRoot,\n\tSleanEventType\n} from './types.js';\nimport { DEV } from '#env';\nimport {\n\tresetValidation,\n\ttrackRuntime,\n\tuntrackRuntime,\n\tvalidateRoot,\n\twarn\n} from './diagnostics.js';\nimport { isDisabled } from './dom.js';\n\n/** Every event type the router can install, in report order. */\nexport const EVENT_TYPES: readonly SleanEventType[] = [\n\t'click',\n\t'dblclick',\n\t'keydown',\n\t'keyup',\n\t'focusin',\n\t'focusout',\n\t'input',\n\t'change',\n\t'pointerdown',\n\t'pointerup',\n\t'pointerover',\n\t'pointerout',\n\t'contextmenu',\n\t'dragenter',\n\t'dragleave',\n\t'drop',\n\t'toggle',\n\t'beforetoggle',\n\t'beforematch',\n\t'reset',\n\t'invalid',\n\t'animationstart'\n];\n\n// `toggle` and `beforetoggle` do not bubble; a root listener only observes them in the capture\n// phase. Every other routed type bubbles, so it stays in the bubble phase and element-level\n// listeners keep their normal ordering. `beforematch` bubbles too (HTML: fired with `bubbles`\n// true), and the browser removes `hidden=\"until-found\"` only after the dispatch has finished, so\n// the bubble phase sees it before the reveal like the capture phase would. `reset` is watched in\n// the capture phase so that application code stopping it cannot hide it (see `routeResets`).\n// `invalid` does not bubble either: it is seen in the capture phase on its way to the control.\nconst CAPTURE: Partial<Record<SleanEventType, true>> = {\n\ttoggle: true,\n\tbeforetoggle: true,\n\treset: true,\n\tinvalid: true\n};\n\n/** Routes an event along a path of elements of the caller's choosing (see `routeResets`). */\nexport type Walk = (path: EventTarget[]) => void;\n\n/**\n * How a form `reset` is routed, installed by `routeResets()` (`./reset.ts`). A `reset` targets the\n * form while the roots that follow it sit inside the form, off the event's path, so it needs a\n * path of its own; only behaviors that handle `reset` import that code.\n */\nlet resetRoute: ((event: Event, walk: Walk) => void) | undefined;\n\n/** @internal Used by `routeResets()`. */\nexport function setResetRoute(route: (event: Event, walk: Walk) => void): void {\n\tresetRoute = route;\n}\n\n/** Development check, run once per registration: every handled event type must be routable. */\nfunction checkEventTypes(name: string, definition: BehaviorDefinition): void {\n\tfor (const type in definition.events) {\n\t\tif (!definition.events[type as SleanEventType]) continue;\n\t\tif (!(EVENT_TYPES as readonly string[]).includes(type)) {\n\t\t\twarn(name, `\"${type}\" is not a routed event type; use a scoped listener instead.`);\n\t\t} else if (type === 'reset' && !resetRoute) {\n\t\t\twarn(name, 'handles \"reset\" but routeResets() was not called before registering it.');\n\t\t}\n\t}\n}\n\n/**\n * Creates a runtime whose shared listeners attach to `root` (`document` by default).\n * Nothing is installed until a behavior that needs an event type is registered.\n */\nexport function createRuntime(options: RuntimeOptions = {}): Runtime {\n\treturn createRuntimeInternal(options.root ?? document);\n}\n\n/** @internal `onDestroy` lets the default-runtime module forget a destroyed instance. */\nexport function createRuntimeInternal(root: RuntimeRoot, onDestroy?: () => void): Runtime {\n\tconst behaviors = new Map<string, BehaviorDefinition>();\n\tconst installed = new Set<SleanEventType>();\n\t// Attribute behaviors (ADR 0009) as [name, definition]: few (usually none), checked on each\n\t// path element.\n\tlet attributes: [string, BehaviorDefinition][] = [];\n\n\t// True while a behavior handler runs: its own stopPropagation is the router's business.\n\tlet routing = false;\n\n\t/**\n\t * Routes `event` to the roots on its path; up to `stop` when application code stopped it\n\t * there (`guard`). Also the root's own listener, where `stop` is never given. A form `reset`\n\t * goes to the route `routeResets()` installed, which calls back with the path to walk.\n\t */\n\tconst route = (event: Event, stop: EventTarget | null = null, path?: EventTarget[]): void => {\n\t\tif (!path) {\n\t\t\tif (event.type === 'reset') return resetRoute?.(event, (roots) => route(event, null, roots));\n\t\t\tpath = event.composedPath();\n\t\t}\n\t\tconst type = event.type as SleanEventType;\n\t\tconst first = path[0] as Node | undefined;\n\t\tconst target = (first && first.nodeType === 1 ? first : event.target) as Element;\n\t\t// No try/finally: Rollup keeps everything inside a try block, development checks included.\n\t\trouting = true;\n\t\twalk: for (let i = 0; i < path.length && path[i - 1] !== stop; i++) {\n\t\t\tconst node = path[i] as HTMLElement;\n\t\t\tif (node.nodeType !== 1) continue;\n\t\t\tfor (let a = 0; a < attributes.length; a++) {\n\t\t\t\tconst [behavior, definition] = attributes[a]!;\n\t\t\t\tconst handler = definition.events?.[type];\n\t\t\t\tif (!handler || !node.hasAttribute(definition.attribute!)) continue;\n\t\t\t\t// Not skipped when disabled: a hint explains a disabled control, and a behavior that\n\t\t\t\t// must not act on one (copy) checks `isDisabled()` itself.\n\t\t\t\tif (DEV) validateRoot(behavior, definition, node);\n\t\t\t\t(handler as BehaviorHandler)({ root: node, target, event, runtime });\n\t\t\t\tif (event.cancelBubble) break walk;\n\t\t\t}\n\t\t\tconst name = node.getAttribute('data-slean');\n\t\t\tif (!name) continue;\n\t\t\tconst definition = behaviors.get(name);\n\t\t\tconst handler = definition?.events?.[type];\n\t\t\tif (!handler || isDisabled(node)) continue;\n\t\t\tif (DEV) validateRoot(name, definition as BehaviorDefinition, node);\n\t\t\t(handler as BehaviorHandler)({ root: node, target, event, runtime });\n\t\t\tif (event.cancelBubble) break walk;\n\t\t}\n\t\trouting = false;\n\t};\n\n\t/**\n\t * Application code may stop an event on its way up — a popover's content stops clicks so the\n\t * table header behind it does not sort — and the router listens on the root, above it: the\n\t * primitives inside that element (a select in the popover) would never hear the click. So\n\t * every bubbling routed event is watched from the capture phase: when application code stops\n\t * it at an element below the root, the roots between the target and that element get it\n\t * first, as they would have natively, and only then does it stop. Roots above it are left\n\t * out, as the stop intends; a stop in the capture phase keeps everything out, as natively; a\n\t * behavior's own stop is the router's.\n\t */\n\tconst guard = (event: Event): void => {\n\t\tconst native = event.stopPropagation;\n\t\tevent.stopPropagation = () => {\n\t\t\tconst at = event.currentTarget;\n\t\t\tif (!routing && !event.cancelBubble && event.eventPhase > 1 && at !== root) route(event, at);\n\t\t\tnative.call(event);\n\t\t};\n\t};\n\n\t// Makes the installed set equal to the set of routed event types some registered behavior\n\t// handles. Unroutable types were reported once, at registration.\n\tconst sync = (): void => {\n\t\tattributes = [...behaviors].filter(([, definition]) => definition.attribute);\n\t\tconst needed = new Set<SleanEventType>();\n\t\tfor (const definition of behaviors.values()) {\n\t\t\tconst events = definition.events;\n\t\t\tfor (const type in events) {\n\t\t\t\tif (!events[type as SleanEventType]) continue;\n\t\t\t\tif ((EVENT_TYPES as readonly string[]).includes(type)) needed.add(type as SleanEventType);\n\t\t\t}\n\t\t}\n\t\tfor (const type of needed) {\n\t\t\tif (installed.has(type)) continue;\n\t\t\troot.addEventListener(type, route, CAPTURE[type] === true);\n\t\t\tif (!CAPTURE[type]) root.addEventListener(type, guard, true);\n\t\t\tinstalled.add(type);\n\t\t}\n\t\tfor (const type of installed) {\n\t\t\tif (needed.has(type)) continue;\n\t\t\troot.removeEventListener(type, route, CAPTURE[type] === true);\n\t\t\tif (!CAPTURE[type]) root.removeEventListener(type, guard, true);\n\t\t\tinstalled.delete(type);\n\t\t}\n\t};\n\n\tconst runtime: Runtime = {\n\t\troot,\n\t\tregister(name, definition) {\n\t\t\tbehaviors.set(name, definition);\n\t\t\tif (DEV) checkEventTypes(name, definition);\n\t\t\tif (DEV) resetValidation();\n\t\t\tsync();\n\t\t},\n\t\tunregister(name) {\n\t\t\tif (behaviors.delete(name)) sync();\n\t\t},\n\t\thas: (name) => behaviors.has(name),\n\t\tbehaviors: () => [...behaviors.keys()],\n\t\tlisteners() {\n\t\t\tconst out: Record<string, number> = {};\n\t\t\tfor (const type of installed) out[type] = 1;\n\t\t\treturn out;\n\t\t},\n\t\tdestroy() {\n\t\t\tbehaviors.clear();\n\t\t\tsync();\n\t\t\tuntrackRuntime(runtime);\n\t\t\tonDestroy?.();\n\t\t}\n\t};\n\ttrackRuntime(runtime);\n\treturn runtime;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EACN,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,IAAI,EACJ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,gEAAgE;AAChE,MAAM,CAAC,MAAM,WAAW,GAA8B;IACrD,OAAO;IACP,UAAU;IACV,SAAS;IACT,OAAO;IACP,SAAS;IACT,UAAU;IACV,OAAO;IACP,QAAQ;IACR,aAAa;IACb,WAAW;IACX,aAAa;IACb,YAAY;IACZ,aAAa;IACb,WAAW;IACX,WAAW;IACX,MAAM;IACN,OAAO;IACP,QAAQ;IACR,cAAc;IACd,aAAa;IACb,OAAO;IACP,SAAS;IACT,gBAAgB;CAChB,CAAC;AAEF,+FAA+F;AAC/F,4FAA4F;AAC5F,8FAA8F;AAC9F,iGAAiG;AACjG,iGAAiG;AACjG,6FAA6F;AAC7F,+FAA+F;AAC/F,MAAM,OAAO,GAA0C;IACtD,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;CACb,CAAC;AAKF;;;;GAIG;AACH,IAAI,UAA4D,CAAC;AAEjE,yCAAyC;AACzC,MAAM,UAAU,aAAa,CAAC,KAAyC;IACtE,UAAU,GAAG,KAAK,CAAC;AACpB,CAAC;AAED,+FAA+F;AAC/F,SAAS,eAAe,CAAC,IAAY,EAAE,UAA8B;IAC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IAAI;QACJ,QAAQ,CAAC,IAAI,EAAE,UAAU;YACxB,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAChC,IAAI,GAAG;gBAAE,eAAe,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAC3C,IAAI,GAAG;gBAAE,eAAe,EAAE,CAAC;YAC3B,IAAI,EAAE,CAAC;QACR,CAAC;QACD,UAAU,CAAC,IAAI;YACd,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;gBAAE,IAAI,EAAE,CAAC;QACpC,CAAC;QACD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;QAClC,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACtC,SAAS;YACR,MAAM,GAAG,GAA2B,EAAE,CAAC;YACvC,KAAK,MAAM,IAAI,IAAI,SAAS;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5C,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,OAAO;YACN,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,EAAE,CAAC;YACP,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB,SAAS,EAAE,EAAE,CAAC;QACf,CAAC;KACD,CAAC;IACF,YAAY,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import type {\n\tBehaviorDefinition,\n\tBehaviorHandler,\n\tRuntime,\n\tRuntimeOptions,\n\tRuntimeRoot,\n\tSleanEventType\n} from './types.js';\nimport { DEV } from '#env';\nimport {\n\tresetValidation,\n\ttrackRuntime,\n\tuntrackRuntime,\n\tvalidateRoot,\n\twarn\n} from './diagnostics.js';\nimport { isDisabled } from './dom.js';\n\n/** Every event type the router can install, in report order. */\nexport const EVENT_TYPES: readonly SleanEventType[] = [\n\t'click',\n\t'dblclick',\n\t'keydown',\n\t'keyup',\n\t'focusin',\n\t'focusout',\n\t'input',\n\t'change',\n\t'pointerdown',\n\t'pointerup',\n\t'pointerover',\n\t'pointerout',\n\t'contextmenu',\n\t'dragenter',\n\t'dragleave',\n\t'drop',\n\t'paste',\n\t'toggle',\n\t'beforetoggle',\n\t'beforematch',\n\t'reset',\n\t'invalid',\n\t'animationstart'\n];\n\n// `toggle` and `beforetoggle` do not bubble; a root listener only observes them in the capture\n// phase. Every other routed type bubbles, so it stays in the bubble phase and element-level\n// listeners keep their normal ordering. `beforematch` bubbles too (HTML: fired with `bubbles`\n// true), and the browser removes `hidden=\"until-found\"` only after the dispatch has finished, so\n// the bubble phase sees it before the reveal like the capture phase would. `reset` is watched in\n// the capture phase so that application code stopping it cannot hide it (see `routeResets`).\n// `invalid` does not bubble either: it is seen in the capture phase on its way to the control.\nconst CAPTURE: Partial<Record<SleanEventType, true>> = {\n\ttoggle: true,\n\tbeforetoggle: true,\n\treset: true,\n\tinvalid: true\n};\n\n/** Routes an event along a path of elements of the caller's choosing (see `routeResets`). */\nexport type Walk = (path: EventTarget[]) => void;\n\n/**\n * How a form `reset` is routed, installed by `routeResets()` (`./reset.ts`). A `reset` targets the\n * form while the roots that follow it sit inside the form, off the event's path, so it needs a\n * path of its own; only behaviors that handle `reset` import that code.\n */\nlet resetRoute: ((event: Event, walk: Walk) => void) | undefined;\n\n/** @internal Used by `routeResets()`. */\nexport function setResetRoute(route: (event: Event, walk: Walk) => void): void {\n\tresetRoute = route;\n}\n\n/** Development check, run once per registration: every handled event type must be routable. */\nfunction checkEventTypes(name: string, definition: BehaviorDefinition): void {\n\tfor (const type in definition.events) {\n\t\tif (!definition.events[type as SleanEventType]) continue;\n\t\tif (!(EVENT_TYPES as readonly string[]).includes(type)) {\n\t\t\twarn(name, `\"${type}\" is not a routed event type; use a scoped listener instead.`);\n\t\t} else if (type === 'reset' && !resetRoute) {\n\t\t\twarn(name, 'handles \"reset\" but routeResets() was not called before registering it.');\n\t\t}\n\t}\n}\n\n/**\n * Creates a runtime whose shared listeners attach to `root` (`document` by default).\n * Nothing is installed until a behavior that needs an event type is registered.\n */\nexport function createRuntime(options: RuntimeOptions = {}): Runtime {\n\treturn createRuntimeInternal(options.root ?? document);\n}\n\n/** @internal `onDestroy` lets the default-runtime module forget a destroyed instance. */\nexport function createRuntimeInternal(root: RuntimeRoot, onDestroy?: () => void): Runtime {\n\tconst behaviors = new Map<string, BehaviorDefinition>();\n\tconst installed = new Set<SleanEventType>();\n\t// Attribute behaviors (ADR 0009) as [name, definition]: few (usually none), checked on each\n\t// path element.\n\tlet attributes: [string, BehaviorDefinition][] = [];\n\n\t// True while a behavior handler runs: its own stopPropagation is the router's business.\n\tlet routing = false;\n\n\t/**\n\t * Routes `event` to the roots on its path; up to `stop` when application code stopped it\n\t * there (`guard`). Also the root's own listener, where `stop` is never given. A form `reset`\n\t * goes to the route `routeResets()` installed, which calls back with the path to walk.\n\t */\n\tconst route = (event: Event, stop: EventTarget | null = null, path?: EventTarget[]): void => {\n\t\tif (!path) {\n\t\t\tif (event.type === 'reset') return resetRoute?.(event, (roots) => route(event, null, roots));\n\t\t\tpath = event.composedPath();\n\t\t}\n\t\tconst type = event.type as SleanEventType;\n\t\tconst first = path[0] as Node | undefined;\n\t\tconst target = (first && first.nodeType === 1 ? first : event.target) as Element;\n\t\t// No try/finally: Rollup keeps everything inside a try block, development checks included.\n\t\trouting = true;\n\t\twalk: for (let i = 0; i < path.length && path[i - 1] !== stop; i++) {\n\t\t\tconst node = path[i] as HTMLElement;\n\t\t\tif (node.nodeType !== 1) continue;\n\t\t\tfor (let a = 0; a < attributes.length; a++) {\n\t\t\t\tconst [behavior, definition] = attributes[a]!;\n\t\t\t\tconst handler = definition.events?.[type];\n\t\t\t\tif (!handler || !node.hasAttribute(definition.attribute!)) continue;\n\t\t\t\t// Not skipped when disabled: a hint explains a disabled control, and a behavior that\n\t\t\t\t// must not act on one (copy) checks `isDisabled()` itself.\n\t\t\t\tif (DEV) validateRoot(behavior, definition, node);\n\t\t\t\t(handler as BehaviorHandler)({ root: node, target, event, runtime });\n\t\t\t\tif (event.cancelBubble) break walk;\n\t\t\t}\n\t\t\tconst name = node.getAttribute('data-slean');\n\t\t\tif (!name) continue;\n\t\t\tconst definition = behaviors.get(name);\n\t\t\tconst handler = definition?.events?.[type];\n\t\t\tif (!handler || isDisabled(node)) continue;\n\t\t\tif (DEV) validateRoot(name, definition as BehaviorDefinition, node);\n\t\t\t(handler as BehaviorHandler)({ root: node, target, event, runtime });\n\t\t\tif (event.cancelBubble) break walk;\n\t\t}\n\t\trouting = false;\n\t};\n\n\t/**\n\t * Application code may stop an event on its way up — a popover's content stops clicks so the\n\t * table header behind it does not sort — and the router listens on the root, above it: the\n\t * primitives inside that element (a select in the popover) would never hear the click. So\n\t * every bubbling routed event is watched from the capture phase: when application code stops\n\t * it at an element below the root, the roots between the target and that element get it\n\t * first, as they would have natively, and only then does it stop. Roots above it are left\n\t * out, as the stop intends; a stop in the capture phase keeps everything out, as natively; a\n\t * behavior's own stop is the router's.\n\t */\n\tconst guard = (event: Event): void => {\n\t\tconst native = event.stopPropagation;\n\t\tevent.stopPropagation = () => {\n\t\t\tconst at = event.currentTarget;\n\t\t\tif (!routing && !event.cancelBubble && event.eventPhase > 1 && at !== root) route(event, at);\n\t\t\tnative.call(event);\n\t\t};\n\t};\n\n\t// Makes the installed set equal to the set of routed event types some registered behavior\n\t// handles. Unroutable types were reported once, at registration.\n\tconst sync = (): void => {\n\t\tattributes = [...behaviors].filter(([, definition]) => definition.attribute);\n\t\tconst needed = new Set<SleanEventType>();\n\t\tfor (const definition of behaviors.values()) {\n\t\t\tconst events = definition.events;\n\t\t\tfor (const type in events) {\n\t\t\t\tif (!events[type as SleanEventType]) continue;\n\t\t\t\tif ((EVENT_TYPES as readonly string[]).includes(type)) needed.add(type as SleanEventType);\n\t\t\t}\n\t\t}\n\t\tfor (const type of needed) {\n\t\t\tif (installed.has(type)) continue;\n\t\t\troot.addEventListener(type, route, CAPTURE[type] === true);\n\t\t\tif (!CAPTURE[type]) root.addEventListener(type, guard, true);\n\t\t\tinstalled.add(type);\n\t\t}\n\t\tfor (const type of installed) {\n\t\t\tif (needed.has(type)) continue;\n\t\t\troot.removeEventListener(type, route, CAPTURE[type] === true);\n\t\t\tif (!CAPTURE[type]) root.removeEventListener(type, guard, true);\n\t\t\tinstalled.delete(type);\n\t\t}\n\t};\n\n\tconst runtime: Runtime = {\n\t\troot,\n\t\tregister(name, definition) {\n\t\t\tbehaviors.set(name, definition);\n\t\t\tif (DEV) checkEventTypes(name, definition);\n\t\t\tif (DEV) resetValidation();\n\t\t\tsync();\n\t\t},\n\t\tunregister(name) {\n\t\t\tif (behaviors.delete(name)) sync();\n\t\t},\n\t\thas: (name) => behaviors.has(name),\n\t\tbehaviors: () => [...behaviors.keys()],\n\t\tlisteners() {\n\t\t\tconst out: Record<string, number> = {};\n\t\t\tfor (const type of installed) out[type] = 1;\n\t\t\treturn out;\n\t\t},\n\t\tdestroy() {\n\t\t\tbehaviors.clear();\n\t\t\tsync();\n\t\t\tuntrackRuntime(runtime);\n\t\t\tonDestroy?.();\n\t\t}\n\t};\n\ttrackRuntime(runtime);\n\treturn runtime;\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* hover card, toast). `contextmenu` is routed for the menu's context-menu module: it bubbles and
|
|
7
7
|
* fires once per request (secondary click, long press, the context-menu key or Shift+F10).
|
|
8
8
|
* `dragenter`, `dragleave` and `drop` are routed for the file drop area; `dragover`, which fires
|
|
9
|
-
* continuously, is not.
|
|
9
|
+
* continuously, is not. `paste` is routed for the file drop area too: the browser fires it,
|
|
10
|
+
* bubbling, at the focused element, so a file input in focus hears an image pasted from the
|
|
11
|
+
* clipboard.
|
|
10
12
|
* `beforematch` is routed for the findable primitive: the browser fires it, bubbling, at a
|
|
11
13
|
* `hidden="until-found"` element that find-in-page or a fragment navigation is about to reveal.
|
|
12
14
|
* `reset` is routed for owned interfaces that draw a native element's value (ADR 0011 §3.5): its
|
|
@@ -16,7 +18,7 @@
|
|
|
16
18
|
* cancelable, at each control that fails constraint validation on submit, `checkValidity()` or
|
|
17
19
|
* `reportValidity()`; the capture phase sees it on the way to the control.
|
|
18
20
|
*/
|
|
19
|
-
export type SleanEventType = 'click' | 'dblclick' | 'keydown' | 'keyup' | 'focusin' | 'focusout' | 'input' | 'change' | 'pointerdown' | 'pointerup' | 'pointerover' | 'pointerout' | 'contextmenu' | 'dragenter' | 'dragleave' | 'drop' | 'toggle' | 'beforetoggle' | 'beforematch' | 'reset' | 'invalid' | 'animationstart';
|
|
21
|
+
export type SleanEventType = 'click' | 'dblclick' | 'keydown' | 'keyup' | 'focusin' | 'focusout' | 'input' | 'change' | 'pointerdown' | 'pointerup' | 'pointerover' | 'pointerout' | 'contextmenu' | 'dragenter' | 'dragleave' | 'drop' | 'paste' | 'toggle' | 'beforetoggle' | 'beforematch' | 'reset' | 'invalid' | 'animationstart';
|
|
20
22
|
/** Native event class per routed event type. */
|
|
21
23
|
export type SleanEventMap = Pick<HTMLElementEventMap, SleanEventType>;
|
|
22
24
|
/** What a behavior handler receives. `target` is the deepest element of the composed path. */
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Event types the shared router is allowed to install. Nothing outside this list is ever\n * installed generically; in particular `pointermove`, `scroll` and `resize` belong to scoped\n * controllers (Tier 2) with an explicit lifetime. `pointerover` and `pointerout` are routed: they\n * bubble and fire when the pointer crosses an element boundary, not on every movement (hint,\n * hover card, toast). `contextmenu` is routed for the menu's context-menu module: it bubbles and\n * fires once per request (secondary click, long press, the context-menu key or Shift+F10).\n * `dragenter`, `dragleave` and `drop` are routed for the file drop area; `dragover`, which fires\n * continuously, is not.\n * `beforematch` is routed for the findable primitive: the browser fires it, bubbling, at a\n * `hidden=\"until-found\"` element that find-in-page or a fragment navigation is about to reveal.\n * `reset` is routed for owned interfaces that draw a native element's value (ADR 0011 §3.5): its\n * target is the form, so the router calls the handlers of the roots that contain the form's\n * controls, one task after the event, when the form has reset them (`routeResets()`).\n * `invalid` is routed for field validation (ADR 0011 §4): the browser fires it, not bubbling and\n * cancelable, at each control that fails constraint validation on submit, `checkValidity()` or\n * `reportValidity()`; the capture phase sees it on the way to the control.\n */\nexport type SleanEventType =\n\t| 'click'\n\t| 'dblclick'\n\t| 'keydown'\n\t| 'keyup'\n\t| 'focusin'\n\t| 'focusout'\n\t| 'input'\n\t| 'change'\n\t| 'pointerdown'\n\t| 'pointerup'\n\t| 'pointerover'\n\t| 'pointerout'\n\t| 'contextmenu'\n\t| 'dragenter'\n\t| 'dragleave'\n\t| 'drop'\n\t| 'toggle'\n\t| 'beforetoggle'\n\t| 'beforematch'\n\t| 'reset'\n\t| 'invalid'\n\t| 'animationstart';\n\n/** Native event class per routed event type. */\nexport type SleanEventMap = Pick<HTMLElementEventMap, SleanEventType>;\n\n/** What a behavior handler receives. `target` is the deepest element of the composed path. */\nexport interface BehaviorContext<E extends Event = Event> {\n\troot: HTMLElement;\n\ttarget: Element;\n\tevent: E;\n\truntime: Runtime;\n}\n\nexport type BehaviorHandler<E extends Event = Event> = (context: BehaviorContext<E>) => void;\n\nexport type BehaviorEvents = {\n\t[K in SleanEventType]?: BehaviorHandler<SleanEventMap[K]>;\n};\n\nexport interface BehaviorDefinition {\n\t/** Runtime tier as declared in the primitive's contract (ADR 0003). Tier 0 never registers. */\n\ttier: 1 | 2;\n\t/** Handlers keyed by event type. Only the listed types get a shared listener. */\n\tevents?: BehaviorEvents;\n\t/**\n\t * An attribute behavior (ADR 0009): its roots are the elements that carry this attribute\n\t * (`data-slean-hint`, `data-slean-copy`) rather than `data-slean=\"<name>\"`, so it can sit on\n\t * any element, a root of another behavior included. Starts with `data-slean-`, or is\n\t * `interestfor`: the platform attribute with which a trigger names its hover card (ADR 0011\n\t * §1.1), so the hover card behavior hears its triggers as well as its `data-slean` cards. The\n\t * router checks it on each element of the event path, beside the `data-slean` marker.\n\t */\n\tattribute?: `data-slean-${string}` | 'interestfor';\n\t/**\n\t * Development-only markup validation. Called once per root on the first routed event, in\n\t * development builds only; each returned string is printed through `warn()`. Primitives may\n\t * strip it from production definitions.\n\t */\n\tvalidate?: (root: HTMLElement) => string[];\n}\n\nexport type RuntimeRoot = Document | ShadowRoot | HTMLElement;\n\nexport interface RuntimeOptions {\n\t/** Event target the shared listeners attach to. Defaults to `document`. */\n\troot?: RuntimeRoot;\n}\n\nexport interface Runtime {\n\treadonly root: RuntimeRoot;\n\t/** Idempotent: registering the same name again replaces the definition without adding listeners. */\n\tregister(name: string, definition: BehaviorDefinition): void;\n\tunregister(name: string): void;\n\thas(name: string): boolean;\n\tbehaviors(): string[];\n\t/** Installed shared listeners per event type; every installed type maps to exactly 1. */\n\tlisteners(): Record<string, number>;\n\t/** Removes every listener and definition. A destroyed runtime must not be reused. */\n\tdestroy(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Event types the shared router is allowed to install. Nothing outside this list is ever\n * installed generically; in particular `pointermove`, `scroll` and `resize` belong to scoped\n * controllers (Tier 2) with an explicit lifetime. `pointerover` and `pointerout` are routed: they\n * bubble and fire when the pointer crosses an element boundary, not on every movement (hint,\n * hover card, toast). `contextmenu` is routed for the menu's context-menu module: it bubbles and\n * fires once per request (secondary click, long press, the context-menu key or Shift+F10).\n * `dragenter`, `dragleave` and `drop` are routed for the file drop area; `dragover`, which fires\n * continuously, is not. `paste` is routed for the file drop area too: the browser fires it,\n * bubbling, at the focused element, so a file input in focus hears an image pasted from the\n * clipboard.\n * `beforematch` is routed for the findable primitive: the browser fires it, bubbling, at a\n * `hidden=\"until-found\"` element that find-in-page or a fragment navigation is about to reveal.\n * `reset` is routed for owned interfaces that draw a native element's value (ADR 0011 §3.5): its\n * target is the form, so the router calls the handlers of the roots that contain the form's\n * controls, one task after the event, when the form has reset them (`routeResets()`).\n * `invalid` is routed for field validation (ADR 0011 §4): the browser fires it, not bubbling and\n * cancelable, at each control that fails constraint validation on submit, `checkValidity()` or\n * `reportValidity()`; the capture phase sees it on the way to the control.\n */\nexport type SleanEventType =\n\t| 'click'\n\t| 'dblclick'\n\t| 'keydown'\n\t| 'keyup'\n\t| 'focusin'\n\t| 'focusout'\n\t| 'input'\n\t| 'change'\n\t| 'pointerdown'\n\t| 'pointerup'\n\t| 'pointerover'\n\t| 'pointerout'\n\t| 'contextmenu'\n\t| 'dragenter'\n\t| 'dragleave'\n\t| 'drop'\n\t| 'paste'\n\t| 'toggle'\n\t| 'beforetoggle'\n\t| 'beforematch'\n\t| 'reset'\n\t| 'invalid'\n\t| 'animationstart';\n\n/** Native event class per routed event type. */\nexport type SleanEventMap = Pick<HTMLElementEventMap, SleanEventType>;\n\n/** What a behavior handler receives. `target` is the deepest element of the composed path. */\nexport interface BehaviorContext<E extends Event = Event> {\n\troot: HTMLElement;\n\ttarget: Element;\n\tevent: E;\n\truntime: Runtime;\n}\n\nexport type BehaviorHandler<E extends Event = Event> = (context: BehaviorContext<E>) => void;\n\nexport type BehaviorEvents = {\n\t[K in SleanEventType]?: BehaviorHandler<SleanEventMap[K]>;\n};\n\nexport interface BehaviorDefinition {\n\t/** Runtime tier as declared in the primitive's contract (ADR 0003). Tier 0 never registers. */\n\ttier: 1 | 2;\n\t/** Handlers keyed by event type. Only the listed types get a shared listener. */\n\tevents?: BehaviorEvents;\n\t/**\n\t * An attribute behavior (ADR 0009): its roots are the elements that carry this attribute\n\t * (`data-slean-hint`, `data-slean-copy`) rather than `data-slean=\"<name>\"`, so it can sit on\n\t * any element, a root of another behavior included. Starts with `data-slean-`, or is\n\t * `interestfor`: the platform attribute with which a trigger names its hover card (ADR 0011\n\t * §1.1), so the hover card behavior hears its triggers as well as its `data-slean` cards. The\n\t * router checks it on each element of the event path, beside the `data-slean` marker.\n\t */\n\tattribute?: `data-slean-${string}` | 'interestfor';\n\t/**\n\t * Development-only markup validation. Called once per root on the first routed event, in\n\t * development builds only; each returned string is printed through `warn()`. Primitives may\n\t * strip it from production definitions.\n\t */\n\tvalidate?: (root: HTMLElement) => string[];\n}\n\nexport type RuntimeRoot = Document | ShadowRoot | HTMLElement;\n\nexport interface RuntimeOptions {\n\t/** Event target the shared listeners attach to. Defaults to `document`. */\n\troot?: RuntimeRoot;\n}\n\nexport interface Runtime {\n\treadonly root: RuntimeRoot;\n\t/** Idempotent: registering the same name again replaces the definition without adding listeners. */\n\tregister(name: string, definition: BehaviorDefinition): void;\n\tunregister(name: string): void;\n\thas(name: string): boolean;\n\tbehaviors(): string[];\n\t/** Installed shared listeners per event type; every installed type maps to exactly 1. */\n\tlisteners(): Record<string, number>;\n\t/** Removes every listener and definition. A destroyed runtime must not be reused. */\n\tdestroy(): void;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svelte-lean/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Svelte Lean runtime kernel: behavior registry, shared event router, DOM and keyboard helpers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ömer Say",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"default": "./dist/index.js"
|
|
17
17
|
},
|
|
18
|
+
"./reorder": {
|
|
19
|
+
"types": "./dist/reorder.d.ts",
|
|
20
|
+
"default": "./dist/reorder.js"
|
|
21
|
+
},
|
|
18
22
|
"./package.json": "./package.json"
|
|
19
23
|
},
|
|
20
24
|
"imports": {
|