@astl/player 0.0.0 → 0.1.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 +48 -0
- package/LICENSE +202 -0
- package/README.md +37 -0
- package/dist/a11y.d.ts +41 -0
- package/dist/a11y.d.ts.map +1 -0
- package/dist/a11y.js +101 -0
- package/dist/a11y.js.map +1 -0
- package/dist/attempt/controller.d.ts +104 -0
- package/dist/attempt/controller.d.ts.map +1 -0
- package/dist/attempt/controller.js +325 -0
- package/dist/attempt/controller.js.map +1 -0
- package/dist/checker/http.d.ts +17 -0
- package/dist/checker/http.d.ts.map +1 -0
- package/dist/checker/http.js +115 -0
- package/dist/checker/http.js.map +1 -0
- package/dist/define.d.ts +35 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +84 -0
- package/dist/define.js.map +1 -0
- package/dist/element/base.d.ts +83 -0
- package/dist/element/base.d.ts.map +1 -0
- package/dist/element/base.js +239 -0
- package/dist/element/base.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/index.d.ts +12 -0
- package/dist/interaction/index.d.ts.map +1 -0
- package/dist/interaction/index.js +4 -0
- package/dist/interaction/index.js.map +1 -0
- package/dist/interaction/keys.d.ts +11 -0
- package/dist/interaction/keys.d.ts.map +1 -0
- package/dist/interaction/keys.js +13 -0
- package/dist/interaction/keys.js.map +1 -0
- package/dist/interaction/pick-and-place.d.ts +120 -0
- package/dist/interaction/pick-and-place.d.ts.map +1 -0
- package/dist/interaction/pick-and-place.js +395 -0
- package/dist/interaction/pick-and-place.js.map +1 -0
- package/dist/interaction/roving-focus.d.ts +44 -0
- package/dist/interaction/roving-focus.d.ts.map +1 -0
- package/dist/interaction/roving-focus.js +115 -0
- package/dist/interaction/roving-focus.js.map +1 -0
- package/dist/messages/en.json +53 -0
- package/dist/messages/help/en.json +14 -0
- package/dist/messages/help/pl.json +14 -0
- package/dist/messages/pl.json +53 -0
- package/dist/messages.d.ts +7 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +18 -0
- package/dist/messages.js.map +1 -0
- package/dist/player/book.d.ts +13 -0
- package/dist/player/book.d.ts.map +1 -0
- package/dist/player/book.js +65 -0
- package/dist/player/book.js.map +1 -0
- package/dist/player/help.d.ts +55 -0
- package/dist/player/help.d.ts.map +1 -0
- package/dist/player/help.js +484 -0
- package/dist/player/help.js.map +1 -0
- package/dist/player/player.d.ts +87 -0
- package/dist/player/player.d.ts.map +1 -0
- package/dist/player/player.js +1229 -0
- package/dist/player/player.js.map +1 -0
- package/dist/player/styled.d.ts +10 -0
- package/dist/player/styled.d.ts.map +1 -0
- package/dist/player/styled.js +213 -0
- package/dist/player/styled.js.map +1 -0
- package/dist/player/styles.d.ts +3 -0
- package/dist/player/styles.d.ts.map +1 -0
- package/dist/player/styles.js +355 -0
- package/dist/player/styles.js.map +1 -0
- package/dist/player/templates.d.ts +25 -0
- package/dist/player/templates.d.ts.map +1 -0
- package/dist/player/templates.js +101 -0
- package/dist/player/templates.js.map +1 -0
- package/dist/player/view.d.ts +44 -0
- package/dist/player/view.d.ts.map +1 -0
- package/dist/player/view.js +231 -0
- package/dist/player/view.js.map +1 -0
- package/dist/runtime.d.ts +45 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +48 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +45 -4
- package/src/a11y.ts +134 -0
- package/src/attempt/controller.ts +381 -0
- package/src/checker/http.ts +149 -0
- package/src/define.ts +114 -0
- package/src/element/base.ts +310 -0
- package/src/index.ts +18 -0
- package/src/interaction/index.ts +11 -0
- package/src/interaction/keys.ts +16 -0
- package/src/interaction/pick-and-place.ts +464 -0
- package/src/interaction/roving-focus.ts +133 -0
- package/src/messages/en.json +53 -0
- package/src/messages/help/en.json +14 -0
- package/src/messages/help/pl.json +14 -0
- package/src/messages/pl.json +53 -0
- package/src/messages.ts +21 -0
- package/src/player/book.ts +70 -0
- package/src/player/help.ts +585 -0
- package/src/player/player.ts +1368 -0
- package/src/player/styled.ts +247 -0
- package/src/player/styles.ts +355 -0
- package/src/player/templates.ts +142 -0
- package/src/player/view.ts +294 -0
- package/src/runtime.ts +95 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { arrowDelta } from './keys.js';
|
|
2
|
+
/** Pointer travel (px) that turns a press into a drag; anything shorter is a tap. */
|
|
3
|
+
export const DRAG_THRESHOLD = 6;
|
|
4
|
+
/**
|
|
5
|
+
* Pick and place, with every way in (WCAG 2.2: 2.1.1 keyboard, 2.5.7 dragging movements):
|
|
6
|
+
* - keyboard: Space or Enter on an item picks it (a native button click), the arrow keys choose a destination (Home
|
|
7
|
+
* and End: the first and the last), Space or Enter on it again puts it there, Escape puts it back;
|
|
8
|
+
* - one pointer, no dragging: tap an item, then a destination (`put`) or another item (with a `place`: put there;
|
|
9
|
+
* without: pick that one instead);
|
|
10
|
+
* - a drag once the pointer travels DRAG_THRESHOLD px, with pointer capture; the click after a drag is not a tap;
|
|
11
|
+
* a touch drags after a long press (`hold`) or from a handle (`handle`), so other touches scroll the page.
|
|
12
|
+
* Escape and a press outside the host work wherever the focus is; held keys do not repeat a pick; Alt, Ctrl and Meta
|
|
13
|
+
* shortcuts stay with the browser; a disabled host forgets any pick. Announcements go through `context.announce`.
|
|
14
|
+
*
|
|
15
|
+
* Wire each item: `@click=${(e) => pick.click(e, id)}`, `@keydown=${(e) => pick.keydown(e, id)}`,
|
|
16
|
+
* `@pointerdown=${(e) => pick.pointerdown(e, id)}` and, for touches that may scroll first (`hold`),
|
|
17
|
+
* `@touchmove=${pick.touchmove}`. A press's moves, release and menu are heard on the document, also for items outside
|
|
18
|
+
* the host.
|
|
19
|
+
*/
|
|
20
|
+
export class PickAndPlace {
|
|
21
|
+
#host;
|
|
22
|
+
#options;
|
|
23
|
+
#picked = null;
|
|
24
|
+
#target = null;
|
|
25
|
+
#said = null;
|
|
26
|
+
#dragging = null;
|
|
27
|
+
#over = null;
|
|
28
|
+
#press = null;
|
|
29
|
+
/** A drag just ended: the click that follows its release is not a tap (keyboard clicks have detail 0). */
|
|
30
|
+
#dragged = false;
|
|
31
|
+
#listening = false;
|
|
32
|
+
constructor(host, options) {
|
|
33
|
+
this.#host = host;
|
|
34
|
+
this.#options = options;
|
|
35
|
+
host.addController(this);
|
|
36
|
+
}
|
|
37
|
+
/** The item picked with the keyboard or a tap, waiting for a destination. */
|
|
38
|
+
get picked() {
|
|
39
|
+
return this.#picked;
|
|
40
|
+
}
|
|
41
|
+
/** The destination the arrow keys chose for the picked item; null: where it is. */
|
|
42
|
+
get target() {
|
|
43
|
+
return this.#target;
|
|
44
|
+
}
|
|
45
|
+
/** The item being dragged. */
|
|
46
|
+
get dragging() {
|
|
47
|
+
return this.#dragging;
|
|
48
|
+
}
|
|
49
|
+
/** The destination under the dragged item. */
|
|
50
|
+
get over() {
|
|
51
|
+
return this.#over;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* While a touch may still scroll (`hold`), the page must not scroll once it drags. Bound on items, not the host:
|
|
55
|
+
* a non-passive touch listener makes the browser wait for it before scrolling.
|
|
56
|
+
*/
|
|
57
|
+
touchmove = {
|
|
58
|
+
handleEvent: (event) => {
|
|
59
|
+
if (this.#press?.dragging && event.cancelable)
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
},
|
|
62
|
+
passive: false,
|
|
63
|
+
};
|
|
64
|
+
hostDisconnected() {
|
|
65
|
+
this.reset();
|
|
66
|
+
this.#fresh();
|
|
67
|
+
}
|
|
68
|
+
hostUpdate() {
|
|
69
|
+
if (this.#host.disabled && (this.#picked !== null || this.#press !== null))
|
|
70
|
+
this.reset();
|
|
71
|
+
}
|
|
72
|
+
/** Picks `item`, announced. */
|
|
73
|
+
pick(item) {
|
|
74
|
+
const at = this.#options.current(item);
|
|
75
|
+
this.#picked = item;
|
|
76
|
+
this.#target = null;
|
|
77
|
+
this.#said = at;
|
|
78
|
+
this.#say('pick', item, at, at);
|
|
79
|
+
this.#changed(item);
|
|
80
|
+
}
|
|
81
|
+
/** Puts the picked item at `to`, announced; where it already is, it goes back (unless the preview is `live`). */
|
|
82
|
+
put(to) {
|
|
83
|
+
const item = this.#picked;
|
|
84
|
+
if (item === null || this.#host.disabled)
|
|
85
|
+
return;
|
|
86
|
+
if (this.#options.preview !== 'live' && to === this.#options.current(item))
|
|
87
|
+
this.cancel();
|
|
88
|
+
else
|
|
89
|
+
this.#place(item, to);
|
|
90
|
+
}
|
|
91
|
+
/** Puts the picked item back where it is, announced. */
|
|
92
|
+
cancel() {
|
|
93
|
+
this.#cancel(true);
|
|
94
|
+
}
|
|
95
|
+
/** Forgets any pick and drag without a word, e.g. when answers are set from outside. */
|
|
96
|
+
reset() {
|
|
97
|
+
this.#endPress();
|
|
98
|
+
this.#picked = null;
|
|
99
|
+
this.#target = null;
|
|
100
|
+
this.#sync();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A click on `item` (a tap, or Space or Enter on its button) picks it. While an item is picked: with a `place` (the
|
|
104
|
+
* clicked item stands for a destination, like a position in a list) the picked item is put there; without, a click
|
|
105
|
+
* on the picked item puts it at its target (or back), and a click on another item picks that one instead.
|
|
106
|
+
*/
|
|
107
|
+
click(event, item, place) {
|
|
108
|
+
if (!this.tap(event) || this.#host.disabled)
|
|
109
|
+
return;
|
|
110
|
+
const picked = this.#picked;
|
|
111
|
+
if (picked === null)
|
|
112
|
+
this.pick(item);
|
|
113
|
+
else if (place !== undefined)
|
|
114
|
+
this.put(place);
|
|
115
|
+
else if (picked !== item)
|
|
116
|
+
this.pick(item);
|
|
117
|
+
else
|
|
118
|
+
this.put(this.#target ?? this.#options.current(item));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Whether a click is a tap (or Space or Enter on a button), not the click a drag's release brings, which it uses up:
|
|
122
|
+
* for clicks that do more than `click`.
|
|
123
|
+
*/
|
|
124
|
+
tap(event) {
|
|
125
|
+
if (!this.#dragged || event.detail === 0)
|
|
126
|
+
return true;
|
|
127
|
+
this.#fresh();
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
/** Arrow keys (and Home, End) on the picked `item` choose its target; returns true when the key was used. */
|
|
131
|
+
keydown(event, item) {
|
|
132
|
+
if (this.#host.disabled)
|
|
133
|
+
return false;
|
|
134
|
+
// A held key repeats clicks: it would pick and put items one after another.
|
|
135
|
+
if (event.repeat && (event.key === 'Enter' || event.key === ' ')) {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
if (event.altKey || event.ctrlKey || event.metaKey || this.#picked !== item)
|
|
140
|
+
return false;
|
|
141
|
+
const options = this.#options;
|
|
142
|
+
const list = options.destinations(item);
|
|
143
|
+
const n = list.length;
|
|
144
|
+
const at = Math.max(0, list.indexOf(this.#target ?? options.current(item)));
|
|
145
|
+
const delta = arrowDelta(event, options.axis ?? 'both', this.#host);
|
|
146
|
+
let next;
|
|
147
|
+
if (delta !== 0)
|
|
148
|
+
next = options.wrap ? (at + delta + n) % n : Math.min(Math.max(at + delta, 0), n - 1);
|
|
149
|
+
else if (event.key === 'Home')
|
|
150
|
+
next = 0;
|
|
151
|
+
else if (event.key === 'End')
|
|
152
|
+
next = n - 1;
|
|
153
|
+
else
|
|
154
|
+
return false;
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
const to = list[next];
|
|
157
|
+
if (next !== at && to !== undefined) {
|
|
158
|
+
const from = this.#said ?? to;
|
|
159
|
+
this.#target = to;
|
|
160
|
+
this.#said = to;
|
|
161
|
+
this.#say('target', item, to, from);
|
|
162
|
+
this.#changed(item);
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
/** A press on `item` with the primary button, a finger or a pen: a tap or the start of a drag. */
|
|
167
|
+
pointerdown(event, item) {
|
|
168
|
+
// A press whose release never came must not leave an item hanging.
|
|
169
|
+
this.#endPress();
|
|
170
|
+
this.#fresh();
|
|
171
|
+
const options = this.#options;
|
|
172
|
+
const touch = event.pointerType === 'touch';
|
|
173
|
+
const handle = options.handle;
|
|
174
|
+
if (this.#host.disabled || !event.isPrimary || event.button !== 0)
|
|
175
|
+
return;
|
|
176
|
+
if (touch &&
|
|
177
|
+
handle &&
|
|
178
|
+
!event.composedPath().some((node) => node instanceof Element && node.matches(handle)))
|
|
179
|
+
return;
|
|
180
|
+
const target = event.currentTarget;
|
|
181
|
+
const press = {
|
|
182
|
+
item,
|
|
183
|
+
pointer: event.pointerId,
|
|
184
|
+
x: event.clientX,
|
|
185
|
+
y: event.clientY,
|
|
186
|
+
box: options.box ? target.closest(options.box) : null,
|
|
187
|
+
armed: !touch || !options.hold,
|
|
188
|
+
dragging: false,
|
|
189
|
+
};
|
|
190
|
+
this.#press = press;
|
|
191
|
+
this.#hear('addEventListener');
|
|
192
|
+
if (!press.armed) {
|
|
193
|
+
press.timer = setTimeout(() => {
|
|
194
|
+
if (this.#press === press && !this.#host.disabled)
|
|
195
|
+
this.#start(press);
|
|
196
|
+
}, options.hold);
|
|
197
|
+
}
|
|
198
|
+
else if (!touch) {
|
|
199
|
+
// Moves and the release outside the item still reach it (touches are captured anyway).
|
|
200
|
+
try {
|
|
201
|
+
target.setPointerCapture(event.pointerId);
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
// A synthetic pointer (not active in the browser) cannot be captured; its events reach the document anyway.
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
#move = (event) => {
|
|
209
|
+
const press = this.#press;
|
|
210
|
+
if (press === null || event.pointerId !== press.pointer)
|
|
211
|
+
return;
|
|
212
|
+
if ((event.buttons & 1) === 0) {
|
|
213
|
+
this.#lost(event);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const dx = event.clientX - press.x;
|
|
217
|
+
const dy = event.clientY - press.y;
|
|
218
|
+
const far = Math.hypot(dx, dy) >= DRAG_THRESHOLD;
|
|
219
|
+
if (!press.armed) {
|
|
220
|
+
// A touch that moves before the long press scrolls the page: let it go.
|
|
221
|
+
if (far)
|
|
222
|
+
this.#endPress();
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!press.dragging) {
|
|
226
|
+
if (!far)
|
|
227
|
+
return;
|
|
228
|
+
this.#start(press);
|
|
229
|
+
}
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
if (press.box !== null)
|
|
232
|
+
press.box.style.translate = `${dx}px ${dy}px`;
|
|
233
|
+
const over = this.#options.at(event.clientX, event.clientY, press.item);
|
|
234
|
+
if (over !== this.#over) {
|
|
235
|
+
this.#over = over;
|
|
236
|
+
this.#host.requestUpdate();
|
|
237
|
+
}
|
|
238
|
+
if (this.#options.preview === 'live' && over !== null && over !== this.#target) {
|
|
239
|
+
this.#target = over;
|
|
240
|
+
this.#changed(press.item);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
#up = (event) => {
|
|
244
|
+
const press = this.#press;
|
|
245
|
+
if (press === null || event.pointerId !== press.pointer)
|
|
246
|
+
return;
|
|
247
|
+
const over = this.#over;
|
|
248
|
+
this.#endPress();
|
|
249
|
+
// Not dragged: a tap, and the click that follows picks or puts.
|
|
250
|
+
if (!press.dragging)
|
|
251
|
+
return;
|
|
252
|
+
const item = press.item;
|
|
253
|
+
const at = this.#options.current(item);
|
|
254
|
+
if (this.#options.preview === 'live')
|
|
255
|
+
this.#place(item, this.#target ?? at);
|
|
256
|
+
else if (over !== null && over !== at)
|
|
257
|
+
this.#place(item, over);
|
|
258
|
+
// A drag is a move of its own: a pick from before it goes back.
|
|
259
|
+
else
|
|
260
|
+
this.#cancel(false);
|
|
261
|
+
};
|
|
262
|
+
/** The pointer was cancelled, lost its capture, or its release was missed. */
|
|
263
|
+
#lost = (event) => {
|
|
264
|
+
const press = this.#press;
|
|
265
|
+
if (press === null || event.pointerId !== press.pointer)
|
|
266
|
+
return;
|
|
267
|
+
this.#endPress();
|
|
268
|
+
if (press.dragging && this.#options.preview === 'live')
|
|
269
|
+
this.#cancel(true);
|
|
270
|
+
};
|
|
271
|
+
/** A long press must not open a menu over the item it is about to drag. */
|
|
272
|
+
#menu = (event) => {
|
|
273
|
+
if (this.#press !== null)
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Focus moving to anything outside the host and its parts. A move to nothing (a tap on something that takes no
|
|
278
|
+
* focus, like a zone) is not leaving: presses outside are handled on their own.
|
|
279
|
+
*/
|
|
280
|
+
#focusin = (event) => {
|
|
281
|
+
if (!this.#press?.dragging && !this.#owns(event.composedPath()))
|
|
282
|
+
this.#leave();
|
|
283
|
+
};
|
|
284
|
+
/** The next press anywhere starts afresh: a touch drag's release brings no click that would use the flag up. */
|
|
285
|
+
#fresh = () => {
|
|
286
|
+
this.#dragged = false;
|
|
287
|
+
document.removeEventListener('pointerdown', this.#fresh, true);
|
|
288
|
+
};
|
|
289
|
+
#outside = (event) => {
|
|
290
|
+
if (!this.#owns(event.composedPath()))
|
|
291
|
+
this.#leave();
|
|
292
|
+
};
|
|
293
|
+
/** Escape cancels a pick or a drag wherever the focus is (a destination button, or nowhere after a tap). */
|
|
294
|
+
#escape = (event) => {
|
|
295
|
+
if (event.key !== 'Escape')
|
|
296
|
+
return;
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
event.stopPropagation();
|
|
299
|
+
this.#endPress();
|
|
300
|
+
this.#cancel(true);
|
|
301
|
+
};
|
|
302
|
+
#start(press) {
|
|
303
|
+
press.armed = true;
|
|
304
|
+
press.dragging = true;
|
|
305
|
+
this.#dragging = press.item;
|
|
306
|
+
if (this.#options.preview === 'live' && this.#picked !== press.item) {
|
|
307
|
+
this.#cancel(false);
|
|
308
|
+
this.#picked = press.item;
|
|
309
|
+
this.#target = null;
|
|
310
|
+
this.#said = this.#options.current(press.item);
|
|
311
|
+
}
|
|
312
|
+
this.#changed(press.item);
|
|
313
|
+
}
|
|
314
|
+
#place(item, to) {
|
|
315
|
+
const from = (item === this.#picked ? this.#said : null) ?? this.#options.current(item);
|
|
316
|
+
this.#picked = null;
|
|
317
|
+
this.#target = null;
|
|
318
|
+
this.#options.commit(item, to);
|
|
319
|
+
this.#say('put', item, to, from);
|
|
320
|
+
this.#changed(item);
|
|
321
|
+
}
|
|
322
|
+
#cancel(announce) {
|
|
323
|
+
const item = this.#picked;
|
|
324
|
+
if (item === null)
|
|
325
|
+
return;
|
|
326
|
+
const at = this.#options.current(item);
|
|
327
|
+
const from = this.#said ?? at;
|
|
328
|
+
this.#picked = null;
|
|
329
|
+
this.#target = null;
|
|
330
|
+
if (announce)
|
|
331
|
+
this.#say('cancel', item, at, from);
|
|
332
|
+
this.#changed(item);
|
|
333
|
+
}
|
|
334
|
+
#leave() {
|
|
335
|
+
const item = this.#picked;
|
|
336
|
+
const to = this.#target;
|
|
337
|
+
if (item === null)
|
|
338
|
+
return;
|
|
339
|
+
if (this.#options.leave === 'drop' && to !== null && to !== this.#options.current(item))
|
|
340
|
+
this.#place(item, to);
|
|
341
|
+
else
|
|
342
|
+
this.#cancel(false);
|
|
343
|
+
}
|
|
344
|
+
#endPress() {
|
|
345
|
+
const press = this.#press;
|
|
346
|
+
if (press === null)
|
|
347
|
+
return;
|
|
348
|
+
clearTimeout(press.timer);
|
|
349
|
+
press.box?.style.removeProperty('translate');
|
|
350
|
+
this.#hear('removeEventListener');
|
|
351
|
+
if (press.dragging) {
|
|
352
|
+
this.#dragged = true;
|
|
353
|
+
document.addEventListener('pointerdown', this.#fresh, true);
|
|
354
|
+
}
|
|
355
|
+
this.#press = null;
|
|
356
|
+
this.#dragging = null;
|
|
357
|
+
this.#over = null;
|
|
358
|
+
this.#sync();
|
|
359
|
+
}
|
|
360
|
+
#say(moment, item, to, from) {
|
|
361
|
+
this.#host.context.announce(this.#options.say(moment, item, to, from));
|
|
362
|
+
}
|
|
363
|
+
#changed(item) {
|
|
364
|
+
this.#options.changed?.(item);
|
|
365
|
+
this.#sync();
|
|
366
|
+
}
|
|
367
|
+
/** Requests a render; Escape, presses and focus outside are heard on the document only while something is picked. */
|
|
368
|
+
#sync() {
|
|
369
|
+
this.#listen();
|
|
370
|
+
this.#host.requestUpdate();
|
|
371
|
+
}
|
|
372
|
+
#listen() {
|
|
373
|
+
const on = this.#host.isConnected && (this.#picked !== null || this.#dragging !== null);
|
|
374
|
+
if (on === this.#listening)
|
|
375
|
+
return;
|
|
376
|
+
this.#listening = on;
|
|
377
|
+
const method = on ? 'addEventListener' : 'removeEventListener';
|
|
378
|
+
document[method]('pointerdown', this.#outside, true);
|
|
379
|
+
document[method]('keydown', this.#escape, true);
|
|
380
|
+
document[method]('focusin', this.#focusin, true);
|
|
381
|
+
}
|
|
382
|
+
/** The moves, release and menu of a press, heard on the document while it lasts (the item may be anywhere). */
|
|
383
|
+
#hear(method) {
|
|
384
|
+
document[method]('pointermove', this.#move);
|
|
385
|
+
document[method]('pointerup', this.#up);
|
|
386
|
+
document[method]('pointercancel', this.#lost);
|
|
387
|
+
document[method]('lostpointercapture', this.#lost);
|
|
388
|
+
document[method]('contextmenu', this.#menu);
|
|
389
|
+
}
|
|
390
|
+
/** Whether an event's composed path runs through the host or one of its parts. */
|
|
391
|
+
#owns(path) {
|
|
392
|
+
return [this.#host, ...(this.#options.parts?.() ?? [])].some((el) => path.includes(el));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=pick-and-place.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick-and-place.js","sourceRoot":"","sources":["../../src/interaction/pick-and-place.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,UAAU,EAAE,MAAM,WAAW,CAAC;AAElD,qFAAqF;AACrF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAyEhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IACd,KAAK,CAAmB;IACxB,QAAQ,CAAyB;IAC1C,OAAO,G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,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import { type Axis } from './keys.js';
|
|
3
|
+
export interface RovingFocusOptions {
|
|
4
|
+
/** How many items share the one tab stop, now. */
|
|
5
|
+
count(): number;
|
|
6
|
+
/** The rendered element of item `index` (focused after a render), or null. */
|
|
7
|
+
item(index: number): HTMLElement | null;
|
|
8
|
+
/** A list along an axis (see `Axis`), or `grid`: rows of `columns` items in reading order. */
|
|
9
|
+
readonly axis: Axis | 'grid';
|
|
10
|
+
/** Items per row of a grid. */
|
|
11
|
+
readonly columns?: number;
|
|
12
|
+
/** Past the last item comes the first (in a grid: the next row, or the top of the column), and back. */
|
|
13
|
+
readonly wrap?: boolean;
|
|
14
|
+
/** Rows that PageUp and PageDown move in a grid. Default 5. */
|
|
15
|
+
readonly page?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Roving tabindex (WAI-ARIA APG): many items, one tab stop. The arrow keys move it (a grid: Left and Right along the
|
|
19
|
+
* row, Up and Down along the column), Home and End go to the ends (a grid: of the row; with Ctrl, of the grid),
|
|
20
|
+
* PageUp and PageDown move a few rows of a grid. Render each item with `tabindex=${roving.tabIndex(i)}`; after a
|
|
21
|
+
* render the active item gets the focus back, but only while the focus is in the host (never pulled from elsewhere).
|
|
22
|
+
* An item the focus moves to by key comes all into view (its scroll margin too), scrolled as little as that needs; one
|
|
23
|
+
* a pointer presses stays where it is.
|
|
24
|
+
*/
|
|
25
|
+
export declare class RovingFocus implements ReactiveController {
|
|
26
|
+
#private;
|
|
27
|
+
constructor(host: ReactiveControllerHost & HTMLElement, options: RovingFocusOptions);
|
|
28
|
+
/** The item with the tab stop. */
|
|
29
|
+
get active(): number;
|
|
30
|
+
tabIndex(index: number): 0 | -1;
|
|
31
|
+
/**
|
|
32
|
+
* Makes item `index` the tab stop and, when the focus is in the host now, moves it there after the next render
|
|
33
|
+
* (also when the render replaces the focused element).
|
|
34
|
+
*/
|
|
35
|
+
focus(index: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Moves the tab stop from item `from` (default: the active one) for a navigation key and returns true (the key is
|
|
38
|
+
* used); false for other keys and for Alt and Meta shortcuts (also Ctrl, except Ctrl+Home and Ctrl+End in a grid).
|
|
39
|
+
*/
|
|
40
|
+
keydown(event: KeyboardEvent, from?: number): boolean;
|
|
41
|
+
hostUpdate(): void;
|
|
42
|
+
hostUpdated(): void;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=roving-focus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roving-focus.d.ts","sourceRoot":"","sources":["../../src/interaction/roving-focus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAC;AACtE,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,WAAW,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,KAAK,IAAI,MAAM,CAAC;IAChB,8EAA8E;IAC9E,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IACxC,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IAC7B,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wGAAwG;IACxG,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,kBAAkB;;IASpD,YAAY,IAAI,EAAE,sBAAsB,GAAG,WAAW,EAAE,OAAO,EAAE,kBAAkB,EAmBlF;IAED,kCAAkC;IAClC,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAE9B;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAMzB;IAED;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,GAAE,MAAqB,GAAG,OAAO,CAmClE;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,WAAW,IAAI,IAAI,CASlB;CACF"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { arrowDelta } from './keys.js';
|
|
2
|
+
/**
|
|
3
|
+
* Roving tabindex (WAI-ARIA APG): many items, one tab stop. The arrow keys move it (a grid: Left and Right along the
|
|
4
|
+
* row, Up and Down along the column), Home and End go to the ends (a grid: of the row; with Ctrl, of the grid),
|
|
5
|
+
* PageUp and PageDown move a few rows of a grid. Render each item with `tabindex=${roving.tabIndex(i)}`; after a
|
|
6
|
+
* render the active item gets the focus back, but only while the focus is in the host (never pulled from elsewhere).
|
|
7
|
+
* An item the focus moves to by key comes all into view (its scroll margin too), scrolled as little as that needs; one
|
|
8
|
+
* a pointer presses stays where it is.
|
|
9
|
+
*/
|
|
10
|
+
export class RovingFocus {
|
|
11
|
+
#host;
|
|
12
|
+
#options;
|
|
13
|
+
#active = 0;
|
|
14
|
+
/** Focus the active item after the next render: the focus was in the host when the move was asked for. */
|
|
15
|
+
#pending = false;
|
|
16
|
+
/** The last input in the host was a pointer's press, not a key. */
|
|
17
|
+
#pressed = false;
|
|
18
|
+
constructor(host, options) {
|
|
19
|
+
this.#host = host;
|
|
20
|
+
this.#options = options;
|
|
21
|
+
host.addController(this);
|
|
22
|
+
// Captured: known before the host's own handlers ask for a move.
|
|
23
|
+
host.addEventListener('pointerdown', () => {
|
|
24
|
+
this.#pressed = true;
|
|
25
|
+
}, { capture: true });
|
|
26
|
+
host.addEventListener('keydown', () => {
|
|
27
|
+
this.#pressed = false;
|
|
28
|
+
}, { capture: true });
|
|
29
|
+
}
|
|
30
|
+
/** The item with the tab stop. */
|
|
31
|
+
get active() {
|
|
32
|
+
return this.#active;
|
|
33
|
+
}
|
|
34
|
+
tabIndex(index) {
|
|
35
|
+
return index === this.#active ? 0 : -1;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Makes item `index` the tab stop and, when the focus is in the host now, moves it there after the next render
|
|
39
|
+
* (also when the render replaces the focused element).
|
|
40
|
+
*/
|
|
41
|
+
focus(index) {
|
|
42
|
+
const host = this.#host;
|
|
43
|
+
const root = host.shadowRoot;
|
|
44
|
+
this.#active = index;
|
|
45
|
+
this.#pending = root ? root.activeElement !== null : host.contains(document.activeElement);
|
|
46
|
+
host.requestUpdate();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Moves the tab stop from item `from` (default: the active one) for a navigation key and returns true (the key is
|
|
50
|
+
* used); false for other keys and for Alt and Meta shortcuts (also Ctrl, except Ctrl+Home and Ctrl+End in a grid).
|
|
51
|
+
*/
|
|
52
|
+
keydown(event, from = this.#active) {
|
|
53
|
+
const options = this.#options;
|
|
54
|
+
const n = options.count();
|
|
55
|
+
const key = event.key;
|
|
56
|
+
const ends = options.axis === 'grid' && (key === 'Home' || key === 'End');
|
|
57
|
+
if (n === 0 || event.altKey || event.metaKey || (event.ctrlKey && !ends))
|
|
58
|
+
return false;
|
|
59
|
+
let to = null;
|
|
60
|
+
if (options.axis !== 'grid') {
|
|
61
|
+
const delta = arrowDelta(event, options.axis, this.#host);
|
|
62
|
+
if (delta !== 0)
|
|
63
|
+
to = options.wrap ? (from + delta + n) % n : Math.min(Math.max(from + delta, 0), n - 1);
|
|
64
|
+
else if (key === 'Home')
|
|
65
|
+
to = 0;
|
|
66
|
+
else if (key === 'End')
|
|
67
|
+
to = n - 1;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const columns = Math.max(1, options.columns ?? 1);
|
|
71
|
+
const column = from % columns;
|
|
72
|
+
const start = from - column;
|
|
73
|
+
const end = Math.min(start + columns, n) - 1;
|
|
74
|
+
const bottom = column + Math.floor((n - 1 - column) / columns) * columns;
|
|
75
|
+
const across = arrowDelta(event, 'inline', this.#host);
|
|
76
|
+
const down = arrowDelta(event, 'block', this.#host);
|
|
77
|
+
const rows = (key === 'PageDown' ? 1 : key === 'PageUp' ? -1 : 0) * (options.page ?? 5);
|
|
78
|
+
if (across !== 0) {
|
|
79
|
+
to = options.wrap ? (from + across + n) % n : Math.min(Math.max(from + across, start), end);
|
|
80
|
+
}
|
|
81
|
+
else if (down !== 0) {
|
|
82
|
+
const next = from + down * columns;
|
|
83
|
+
to = next >= 0 && next < n ? next : !options.wrap ? from : down > 0 ? column : bottom;
|
|
84
|
+
}
|
|
85
|
+
else if (rows !== 0)
|
|
86
|
+
to = Math.min(Math.max(from + rows * columns, column), bottom);
|
|
87
|
+
else if (key === 'Home')
|
|
88
|
+
to = event.ctrlKey ? 0 : start;
|
|
89
|
+
else if (key === 'End')
|
|
90
|
+
to = event.ctrlKey ? n - 1 : end;
|
|
91
|
+
}
|
|
92
|
+
if (to === null)
|
|
93
|
+
return false;
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
this.focus(to);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
hostUpdate() {
|
|
99
|
+
this.#active = Math.max(0, Math.min(this.#active, this.#options.count() - 1));
|
|
100
|
+
}
|
|
101
|
+
hostUpdated() {
|
|
102
|
+
if (!this.#pending)
|
|
103
|
+
return;
|
|
104
|
+
this.#pending = false;
|
|
105
|
+
const target = this.#options.item(this.#active);
|
|
106
|
+
if (target === null || (this.#host.shadowRoot ?? document).activeElement === target)
|
|
107
|
+
return;
|
|
108
|
+
target.focus();
|
|
109
|
+
// focus() centres an item it finds hidden, but one partly hidden sideways stays cut (Chromium). After a press,
|
|
110
|
+
// nothing more: scrolling would move what is under the pointer (a word search reads a drag from where letters are).
|
|
111
|
+
if (!this.#pressed)
|
|
112
|
+
target.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=roving-focus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roving-focus.js","sourceRoot":"","sources":["../../src/interaction/roving-focus.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAE,MAAM,WAAW,CAAC;AAiBlD;;;;;;;GAOG;AACH,MAAM,OAAO,WAAW;IACb,KAAK,CAAuC;IAC5C,QAAQ,CAAqB;IACtC,OAAO,GAAG,CAAC,CAAC;IACZ,0GAA0G;IAC1G,QAAQ,GAAG,KAAK,CAAC;IACjB,mEAAmE;IACnE,QAAQ,GAAG,KAAK,CAAC;IAEjB,YAAY,IAA0C,EAAE,OAA2B;QACjF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzB,iEAAiE;QACjE,IAAI,CAAC,gBAAgB,CACnB,aAAa,EACb,GAAG,EAAE;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,CAAC,EACD,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;QACF,IAAI,CAAC,gBAAgB,CACnB,SAAS,EACT,GAAG,EAAE;YACH,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACxB,CAAC,EACD,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;IACJ,CAAC;IAED,kCAAkC;IAClC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,QAAQ,CAAC,KAAa;QACpB,OAAO,KAAK,KAAK,IAAI,CAAC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AI,CAAC;IACd,CAAC;IAED,UAAU;QACR,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,WAAW;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,QAAQ,CAAC,CAAC,aAAa,KAAK,MAAM;YAAE,OAAO;QAC5F,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,+GAA+G;QAC/G,oHAAoH;QACpH,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACrF,CAAC;CACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"loading": "Loading the exercise…",
|
|
3
|
+
"page.heading": "Page {n}",
|
|
4
|
+
"page.counter": "Page {n} of {total}",
|
|
5
|
+
"page.counter.spread": "Pages {from}-{to} of {total}",
|
|
6
|
+
"progress.label": "Pages",
|
|
7
|
+
"progress.item": "Page {n}, {state, select, done {answered} partial {partly answered} other {not answered}}",
|
|
8
|
+
"nav.previous": "Back",
|
|
9
|
+
"nav.next": "Next",
|
|
10
|
+
"action.check": "Check",
|
|
11
|
+
"action.reset": "Start over",
|
|
12
|
+
"action.submit": "Hand in",
|
|
13
|
+
"confirm.empty": "{count, plural, one {You have # empty answer.} other {You have # empty answers.}} Hand in anyway?",
|
|
14
|
+
"confirm.submit": "Hand in anyway",
|
|
15
|
+
"confirm.cancel": "Back to the answers",
|
|
16
|
+
"checks.left": "{count, plural, =0 {No checks left} one {# check left} other {# checks left}}",
|
|
17
|
+
"result.title": "Result",
|
|
18
|
+
"result.score": "{score} of {max, plural, one {# point} other {# points}}",
|
|
19
|
+
"result.count": "{verdict}: {count}",
|
|
20
|
+
"result.passed": "Passed",
|
|
21
|
+
"result.notPassed": "Not passed yet",
|
|
22
|
+
"result.submitted": "Your answers have been handed in.",
|
|
23
|
+
"result.later": "You will see your results later.",
|
|
24
|
+
"result.teacher.sent": "Your answers were sent to your teacher.",
|
|
25
|
+
"result.teacher.count": "{count, plural, =0 {No answer goes to your teacher to mark.} one {# answer goes to your teacher to mark.} other {# answers go to your teacher to mark.}}",
|
|
26
|
+
"result.teacher.unchecked": "Answers for your teacher are not checked here.",
|
|
27
|
+
"result.practice": "Practice only: nothing here is scored.",
|
|
28
|
+
"result.announce": "Result: {score}.",
|
|
29
|
+
"result.countAnnounce": "{verdict}: {count}.",
|
|
30
|
+
"verdict.correct": "Correct",
|
|
31
|
+
"verdict.partial": "Partly correct",
|
|
32
|
+
"verdict.incorrect": "Not yet",
|
|
33
|
+
"verdict.empty": "No answer",
|
|
34
|
+
"timer.label": "Time left",
|
|
35
|
+
"timer.minutes": "{minutes, plural, one {# minute left} other {# minutes left}}",
|
|
36
|
+
"timer.expired": "Time is up. Your answers are being handed in.",
|
|
37
|
+
"unsupported": "This part of the exercise does not work in this player.",
|
|
38
|
+
"error.invalid_request": "Your answers could not be sent. Try again.",
|
|
39
|
+
"error.unauthorized": "We could not confirm who you are. Sign in and try again.",
|
|
40
|
+
"error.check_not_allowed": "Checking is turned off in this exercise.",
|
|
41
|
+
"error.checks_exhausted": "You have no checks left.",
|
|
42
|
+
"error.not_found": "This exercise could not be found.",
|
|
43
|
+
"error.method_not_allowed": "The exercise server turned the request down.",
|
|
44
|
+
"error.attempt_closed": "These answers have already been handed in.",
|
|
45
|
+
"error.payload_too_large": "Your answers are too long to send.",
|
|
46
|
+
"error.internal_error": "We could not reach the exercise server. Try again in a moment.",
|
|
47
|
+
"error.no_checker": "This exercise cannot be checked here.",
|
|
48
|
+
"error.load_failed": "The exercise could not be loaded.",
|
|
49
|
+
"error.view_invalid": "The exercise file is damaged.",
|
|
50
|
+
"error.integrity_mismatch": "The exercise file did not pass verification, so it was not opened.",
|
|
51
|
+
"error.source_needs_compiler": "This exercise needs the full Astrolabe script to run.",
|
|
52
|
+
"error.source_invalid": "This exercise is not written correctly, so it cannot be shown."
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"help.label": "Help with this question",
|
|
3
|
+
"help.labelField": "Help with field {n}",
|
|
4
|
+
"help.labelPage": "Help with this page",
|
|
5
|
+
"help.hint": "Hint ({n}/{total})",
|
|
6
|
+
"help.hintCost": "Costs {percent}% of the points",
|
|
7
|
+
"help.hintItem": "Hint {n}",
|
|
8
|
+
"help.hintAnnounce": "Hint {n}: {text}",
|
|
9
|
+
"help.check": "this question",
|
|
10
|
+
"help.checkField": "field {n}",
|
|
11
|
+
"help.why": "Why?",
|
|
12
|
+
"error.hints_not_allowed": "Hints are not available in this exercise.",
|
|
13
|
+
"error.hints_exhausted": "There are no more hints."
|
|
14
|
+
}
|