@quillmark/svelte 0.33.0 → 0.34.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/README.md +73 -1
- package/THEMING.md +11 -10
- package/dist/core/codec/anchor.d.ts +12 -0
- package/dist/core/codec/anchor.js +39 -0
- package/dist/core/codec/drag-move.d.ts +11 -0
- package/dist/core/codec/drag-move.js +143 -0
- package/dist/core/codec/encode.js +14 -5
- package/dist/core/codec/field.d.ts +47 -1
- package/dist/core/codec/field.js +147 -38
- package/dist/core/codec/index.d.ts +8 -2
- package/dist/core/codec/index.js +9 -2
- package/dist/core/codec/islands.d.ts +4 -1
- package/dist/core/codec/islands.js +6 -0
- package/dist/core/codec/keymap.d.ts +3 -0
- package/dist/core/codec/keymap.js +13 -12
- package/dist/core/codec/leave.d.ts +17 -0
- package/dist/core/codec/leave.js +78 -0
- package/dist/core/codec/prose.css +217 -0
- package/dist/core/codec/review-diff.d.ts +12 -0
- package/dist/core/codec/review-diff.js +131 -0
- package/dist/core/codec/review.d.ts +131 -0
- package/dist/core/codec/review.js +1077 -0
- package/dist/core/codec/shortcuts.d.ts +20 -4
- package/dist/core/codec/shortcuts.js +27 -7
- package/dist/core/codec/slash.d.ts +3 -0
- package/dist/core/codec/slash.js +2 -1
- package/dist/core/codec/table-view.js +163 -25
- package/dist/core/codec/undo.d.ts +6 -0
- package/dist/core/codec/undo.js +25 -2
- package/dist/core/dragfollow.d.ts +18 -0
- package/dist/core/dragfollow.js +63 -0
- package/dist/core/theme.css +36 -7
- package/dist/preview/controller.js +16 -0
- package/dist/preview/strings.d.ts +4 -0
- package/dist/preview/strings.js +3 -1
- package/dist/visual/ArrayField.svelte +363 -57
- package/dist/visual/ArrayField.svelte.d.ts +5 -0
- package/dist/visual/BooleanField.svelte +60 -5
- package/dist/visual/BooleanField.svelte.d.ts +2 -1
- package/dist/visual/Card.svelte +27 -17
- package/dist/visual/CardControls.svelte +17 -7
- package/dist/visual/CardControls.svelte.d.ts +2 -0
- package/dist/visual/DateField.svelte +90 -39
- package/dist/visual/DateField.svelte.d.ts +2 -2
- package/dist/visual/Field.svelte +126 -6
- package/dist/visual/FieldHint.svelte +24 -9
- package/dist/visual/FieldLabel.svelte +128 -22
- package/dist/visual/FieldLabel.svelte.d.ts +9 -0
- package/dist/visual/FormatPopover.svelte +125 -20
- package/dist/visual/MatrixAdd.svelte +13 -6
- package/dist/visual/MatrixAdd.svelte.d.ts +3 -2
- package/dist/visual/MatrixField.svelte +36 -8
- package/dist/visual/NumberField.svelte +27 -6
- package/dist/visual/NumberField.svelte.d.ts +3 -0
- package/dist/visual/ObjectField.svelte +25 -1
- package/dist/visual/ObjectField.svelte.d.ts +6 -0
- package/dist/visual/ProseField.svelte +23 -0
- package/dist/visual/ProseField.svelte.d.ts +3 -0
- package/dist/visual/ProseValue.svelte +107 -17
- package/dist/visual/ProseValue.svelte.d.ts +18 -4
- package/dist/visual/ReviewPopover.svelte +179 -0
- package/dist/visual/ReviewPopover.svelte.d.ts +16 -0
- package/dist/visual/ReviewProposal.svelte +149 -0
- package/dist/visual/ReviewProposal.svelte.d.ts +15 -0
- package/dist/visual/ReviewRows.svelte +68 -0
- package/dist/visual/ReviewRows.svelte.d.ts +11 -0
- package/dist/visual/SlashMenu.svelte +13 -1
- package/dist/visual/SlashMenu.svelte.d.ts +2 -0
- package/dist/visual/VisualEditor.svelte +23 -0
- package/dist/visual/VisualEditor.svelte.d.ts +7 -0
- package/dist/visual/VisualEditorInner.svelte +671 -22
- package/dist/visual/VisualEditorInner.svelte.d.ts +7 -0
- package/dist/visual/controls.css +17 -2
- package/dist/visual/guidance.d.ts +12 -0
- package/dist/visual/guidance.js +37 -2
- package/dist/visual/icons/nodes.d.ts +14 -2
- package/dist/visual/icons/nodes.js +12 -1
- package/dist/visual/index.d.ts +6 -0
- package/dist/visual/index.js +2 -0
- package/dist/visual/listhistory.d.ts +36 -0
- package/dist/visual/listhistory.js +53 -0
- package/dist/visual/proposals.d.ts +40 -0
- package/dist/visual/proposals.js +219 -0
- package/dist/visual/props.d.ts +35 -0
- package/dist/visual/removed.d.ts +20 -0
- package/dist/visual/removed.js +30 -0
- package/dist/visual/review.d.ts +170 -0
- package/dist/visual/review.js +269 -0
- package/dist/visual/review.svelte.d.ts +106 -0
- package/dist/visual/review.svelte.js +356 -0
- package/dist/visual/rowdrag.svelte.js +44 -55
- package/dist/visual/strings.d.ts +48 -7
- package/dist/visual/strings.js +32 -7
- package/dist/visual/structure.d.ts +5 -0
- package/dist/visual/structure.js +1 -1
- package/dist/visual/undo.svelte.d.ts +40 -7
- package/dist/visual/undo.svelte.js +98 -25
- package/package.json +1 -1
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
`writer.set(field, wholeArray)` (arrays are not op-addressed). Element control
|
|
5
5
|
by `items.type`: `richtext` / `text` → a prose element
|
|
6
6
|
({@link ProseValue}), `object` → a summary row that opens onto a subform, or a
|
|
7
|
-
table's row where the array asks for one and the cells are short,
|
|
8
|
-
a
|
|
7
|
+
table's row where the array asks for one and the cells are short, a number, an enum, a
|
|
8
|
+
boolean or a date → that type's own control, everything else → a text input. The add
|
|
9
|
+
chip sits in the label header row (space-between with the field
|
|
9
10
|
label); {@link Field} skips its own label for array controls and hands this component
|
|
10
11
|
the label track with it. An array declaring `max:` disables the chip at the cap and
|
|
11
12
|
draws the count beside it: a disabled button takes no focus, so a `title` reaches
|
|
@@ -13,6 +14,9 @@
|
|
|
13
14
|
|
|
14
15
|
An `object` element collapses: the row is its own summary — a box titled `Item` and
|
|
15
16
|
its 1-based number, whatever the record holds — and opens onto {@link ObjectField}.
|
|
17
|
+
Collapsed, the summary draws the words of the record's first one-line text cell after
|
|
18
|
+
the title, at the label ink: what tells one closed row from the next, and no part of
|
|
19
|
+
the row's name.
|
|
16
20
|
Open, the summary keeps its words, its chevron and its remove where they stood, and
|
|
17
21
|
lets its box go: a line at the tap rung over the subform, so the one thing a press
|
|
18
22
|
on it moves is the chevron. Each row opens and closes on its own: a
|
|
@@ -38,27 +42,44 @@
|
|
|
38
42
|
every other field's control does. On an object element that box is the summary rather
|
|
39
43
|
than the open row: a destructive control belongs to the line it sits on, not to
|
|
40
44
|
everything that line has unfolded. A table's row carries the remove alone, in its last
|
|
41
|
-
track and pinned to the end edge of the box the table scrolls in
|
|
42
|
-
row
|
|
43
|
-
|
|
45
|
+
track and pinned to the end edge of the box the table scrolls in, so the one control
|
|
46
|
+
the row draws never needs a scroll to reach. A table's row and a line carry no handle:
|
|
47
|
+
their reorder is the key's alone.
|
|
44
48
|
|
|
45
49
|
Keys carry the list without the mouse: Enter inserts a sibling below and takes the
|
|
46
|
-
caret there,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
caret there, and short of a prose line's end splits the line there, as a bulleted list
|
|
51
|
+
does; a paste of several lines into a prose row opens a row per line; Backspace at a
|
|
52
|
+
prose line's start joins it onto the line above and Delete at its end joins the next
|
|
53
|
+
onto it, each one commit; Backspace on an empty element removes it and hands focus back up the list, Alt+↑/↓
|
|
54
|
+
anywhere in a row of the list moves it, the nearest row answering and never
|
|
55
|
+
the record around a nested one, and on an `object` row is the twin of the handle's drag. A move is one splice of the ids
|
|
50
56
|
and of the values together, the mechanism insert and remove use, so an element keeps
|
|
51
57
|
its id for life and no prose leaf inside it remounts; the open row stays open across
|
|
52
58
|
its own move, and `animate:reorder` holds the moving row as it holds a card.
|
|
53
59
|
|
|
60
|
+
A change to the rows (an insert, a remove, a split, a join, a paste over rows, a move)
|
|
61
|
+
is a step of the list's own, since no leaf's history holds it: ⌘/Ctrl+Z anywhere in the
|
|
62
|
+
list takes the latest back and ⌘/Ctrl+Shift+Z puts it forward, the nearest list
|
|
63
|
+
answering, while the rows stand as that step left them. An edit in a row since is the
|
|
64
|
+
row's to undo first. A removal offered on the toast is the same step.
|
|
65
|
+
|
|
54
66
|
An empty list of lines (any element but an `object`) draws a standing row to type
|
|
55
67
|
into, so a list's first line takes no press of the add chip first. The row is not an
|
|
56
|
-
element and draws as one that is not there yet: a row's own box
|
|
57
|
-
|
|
68
|
+
element and draws as one that is not there yet: a row's own box with no remove, holding
|
|
69
|
+
the words `arrayStanding` where its control ghosts words and muted where it cannot. Nothing commits until it holds something, so the field
|
|
58
70
|
stays where it was, absent or `[]`, and Enter and Backspace have nothing to act on.
|
|
59
71
|
Its first non-empty edit or paste commits it as the list's first element, keeping its
|
|
60
72
|
id, so the caret stays in the leaf it is typing into.
|
|
61
73
|
|
|
74
|
+
A scalar element's row is its type's control, and the row's keys are that control's:
|
|
75
|
+
Enter and Backspace are a line's, so the remove is a tab stop here. A new row holds
|
|
76
|
+
what the type holds empty: the blank for an enum or a date, `false` for a boolean. A
|
|
77
|
+
number has no empty answer, so the add chip opens a standing row after the last
|
|
78
|
+
element, which commits once it holds a number and which its remove dismisses, and a
|
|
79
|
+
number row emptied is a row removed, offered back on the toast. Enter in a number row
|
|
80
|
+
holding a number moves on, as on a line: to the next row with its number selected, or
|
|
81
|
+
from the last to the standing row.
|
|
82
|
+
|
|
62
83
|
An unset array whose `default:` holds elements draws them as its rows, at the default
|
|
63
84
|
rung (`data-default` on the rows' box), since they are what prints. The rows are the
|
|
64
85
|
declared literal rather than resolve's form, which completes a record against `items`:
|
|
@@ -83,20 +104,36 @@
|
|
|
83
104
|
IdSeq,
|
|
84
105
|
baseType,
|
|
85
106
|
controlKind,
|
|
107
|
+
firstShortText,
|
|
86
108
|
declaredContent,
|
|
87
109
|
fieldTitle,
|
|
88
110
|
literalText,
|
|
111
|
+
renderedBoolean,
|
|
89
112
|
schemaAt,
|
|
90
113
|
textCap,
|
|
91
114
|
type ArrayLayout
|
|
92
115
|
} from './structure.js';
|
|
116
|
+
import { splitReview, type DeepReview } from './review.js';
|
|
117
|
+
import ReviewRows from './ReviewRows.svelte';
|
|
93
118
|
import { splitDeep, unrouted, type DeepDiagnostic } from './diagnostics.js';
|
|
94
119
|
import { propertyDomIds } from './domid.js';
|
|
95
120
|
import type { LandingBox } from './leaves.js';
|
|
96
121
|
import { reorder, reorderArm } from './motion.js';
|
|
97
122
|
import { rowDrag } from './rowdrag.svelte.js';
|
|
123
|
+
import {
|
|
124
|
+
listHistory,
|
|
125
|
+
sameValues,
|
|
126
|
+
undoChord,
|
|
127
|
+
type ListFocus,
|
|
128
|
+
type ListRows,
|
|
129
|
+
type ListStep
|
|
130
|
+
} from './listhistory.js';
|
|
98
131
|
import Icon from './icons/Icon.svelte';
|
|
99
132
|
import TextField from './TextField.svelte';
|
|
133
|
+
import NumberField from './NumberField.svelte';
|
|
134
|
+
import EnumField from './EnumField.svelte';
|
|
135
|
+
import BooleanField from './BooleanField.svelte';
|
|
136
|
+
import DateField from './DateField.svelte';
|
|
100
137
|
import ObjectField from './ObjectField.svelte';
|
|
101
138
|
import ProseValue from './ProseValue.svelte';
|
|
102
139
|
import FieldLabel from './FieldLabel.svelte';
|
|
@@ -145,6 +182,10 @@
|
|
|
145
182
|
* naming a row draws under that row — under its head while it is collapsed, under
|
|
146
183
|
* the cell once it is open — and one naming no row draws at the list's foot. */
|
|
147
184
|
diagnostics?: readonly DeepDiagnostic[];
|
|
185
|
+
/** The review items naming a place inside this list, each with its steps still to
|
|
186
|
+
* walk from it: a member's under its row, a record's cell handed to the open row
|
|
187
|
+
* that draws it, and a member past the last at the list's foot (`ReviewRows`). */
|
|
188
|
+
review?: readonly DeepReview[];
|
|
148
189
|
}
|
|
149
190
|
let {
|
|
150
191
|
value,
|
|
@@ -159,7 +200,8 @@
|
|
|
159
200
|
idBase,
|
|
160
201
|
contentAt,
|
|
161
202
|
onCommit,
|
|
162
|
-
diagnostics
|
|
203
|
+
diagnostics,
|
|
204
|
+
review
|
|
163
205
|
}: Props = $props();
|
|
164
206
|
|
|
165
207
|
// The element control is the item schema's own, with no departure: a content-typed
|
|
@@ -192,6 +234,23 @@
|
|
|
192
234
|
const foot = $derived(
|
|
193
235
|
unrouted(routed, (step) => typeof step === 'number' && step >= 0 && step < arr.length)
|
|
194
236
|
);
|
|
237
|
+
const reviewed = $derived(splitReview(review));
|
|
238
|
+
/** A row's review items: the member's own, and those inside it. */
|
|
239
|
+
const rowReview = (k: number): DeepReview[] =>
|
|
240
|
+
k < arr.length ? (reviewed.below.get(k) ?? []) : [];
|
|
241
|
+
const ownReview = (k: number): DeepReview[] => rowReview(k).filter((e) => !e.steps.length);
|
|
242
|
+
const innerReview = (k: number): DeepReview[] => rowReview(k).filter((e) => e.steps.length);
|
|
243
|
+
/** What has no row to draw under: a member past the last, and a place no row holds. A
|
|
244
|
+
* table's rows are cells alone, so a member's own item is drawn here too, by its number. */
|
|
245
|
+
const reviewFoot = $derived([
|
|
246
|
+
...reviewed.here,
|
|
247
|
+
...[...reviewed.below].flatMap(([step, list]) => {
|
|
248
|
+
const held = typeof step === 'number' && step >= 0 && step < arr.length;
|
|
249
|
+
return list
|
|
250
|
+
.filter((e) => !held || (table && !e.steps.length))
|
|
251
|
+
.map((e) => ({ steps: [step, ...e.steps], item: e.item }));
|
|
252
|
+
})
|
|
253
|
+
]);
|
|
195
254
|
|
|
196
255
|
// Parallel stable ids, one per element, kept in lockstep with the data below.
|
|
197
256
|
// Seeded eagerly so a non-empty array renders its rows on the first pass:
|
|
@@ -202,12 +261,24 @@
|
|
|
202
261
|
// The standing row's id, taken at its first commit and replaced: the row it
|
|
203
262
|
// becomes keeps the id, so its leaf never remounts under the keystroke.
|
|
204
263
|
let standingId = $state(seq.next());
|
|
264
|
+
// A boolean row is never empty, so a list of them has no row that is not one yet.
|
|
205
265
|
const standing = $derived(
|
|
206
|
-
!table &&
|
|
266
|
+
!table &&
|
|
267
|
+
control !== 'object' &&
|
|
268
|
+
control !== 'boolean' &&
|
|
269
|
+
arr.length === 0 &&
|
|
270
|
+
(max == null || max > 0)
|
|
207
271
|
);
|
|
208
272
|
/** Whether the standing row is drawn: a gesture lands on it, which holds no element yet. */
|
|
209
273
|
const onStanding = $derived(standing && ids.length === 0);
|
|
210
|
-
|
|
274
|
+
/** The add chip's standing row after a list of numbers (see the header). */
|
|
275
|
+
let adding = $state(false);
|
|
276
|
+
const pending = $derived(adding && control === 'number' && ids.length > 0 && !atCap);
|
|
277
|
+
const rowIds = $derived(onStanding ? [standingId] : pending ? [...ids, standingId] : ids);
|
|
278
|
+
/** Whether the element's keys are its control's own, the row wiring none. */
|
|
279
|
+
const scalar = $derived(
|
|
280
|
+
control === 'number' || control === 'enum' || control === 'boolean' || control === 'date'
|
|
281
|
+
);
|
|
211
282
|
// Length reconcile (defend against an out-of-band length change);
|
|
212
283
|
// order is maintained by the mutators, not here.
|
|
213
284
|
$effect(() => {
|
|
@@ -235,8 +306,26 @@
|
|
|
235
306
|
// it says so once per element per render. Thirteen lines on one memo's first paint,
|
|
236
307
|
// in the console a consumer is reading to find its own defects. Same shape
|
|
237
308
|
// {@link Card} keeps its header/panel refs in.
|
|
238
|
-
const els: Record<
|
|
239
|
-
|
|
309
|
+
const els: Record<
|
|
310
|
+
string,
|
|
311
|
+
| {
|
|
312
|
+
focus: () => void;
|
|
313
|
+
setCaret?: (pos: number) => void;
|
|
314
|
+
caret?: () => number | undefined;
|
|
315
|
+
current?: () => Content | undefined;
|
|
316
|
+
appended?: (tail: Content) => { content: Content; caret: number } | undefined;
|
|
317
|
+
}
|
|
318
|
+
| undefined
|
|
319
|
+
> = $state({});
|
|
320
|
+
/** Focus row `id`'s control: through its handle where it exports one, else the first
|
|
321
|
+
* control the row's markup holds, its remove aside. */
|
|
322
|
+
function focusRow(id: string): void {
|
|
323
|
+
const el = els[id];
|
|
324
|
+
if (el) return el.focus();
|
|
325
|
+
[...(rowEls[id]?.querySelectorAll<HTMLElement>('input, button') ?? [])]
|
|
326
|
+
.find((n) => !n.classList.contains('qm-remove'))
|
|
327
|
+
?.focus();
|
|
328
|
+
}
|
|
240
329
|
// The rows' own boxes, on the same key and dropped on the same paths: what an
|
|
241
330
|
// element landing blooms in ({@link focusPath}), and what an object row's
|
|
242
331
|
// summary is found through. A row is a box whatever its element type, so the two
|
|
@@ -285,6 +374,9 @@
|
|
|
285
374
|
if (open.has(id)) open.delete(id);
|
|
286
375
|
else open.add(id);
|
|
287
376
|
}
|
|
377
|
+
/** What a collapsed row shows of its record: the cell a card's title reads. */
|
|
378
|
+
const preview = (k: number): string | undefined =>
|
|
379
|
+
firstShortText(items?.properties, (arr[k] ?? {}) as Record<string, unknown>);
|
|
288
380
|
const rowName = (k: number): string | undefined =>
|
|
289
381
|
label != null ? `${label} ${k + 1}` : undefined;
|
|
290
382
|
/** A row control's name: its action, and the row, where the row has a name. */
|
|
@@ -308,35 +400,45 @@
|
|
|
308
400
|
function emptyElement(): unknown {
|
|
309
401
|
if (control === 'prose') return emptyContent();
|
|
310
402
|
if (control === 'object') return {};
|
|
403
|
+
if (control === 'boolean') return false;
|
|
311
404
|
return '';
|
|
312
405
|
}
|
|
313
406
|
|
|
314
|
-
/** The standing row becomes the list's first
|
|
407
|
+
/** The standing row becomes an element, the list's first or its last, keeping its id. */
|
|
315
408
|
function claimStanding(): void {
|
|
316
|
-
ids = [standingId];
|
|
409
|
+
ids = [...ids, standingId];
|
|
317
410
|
standingId = seq.next();
|
|
411
|
+
adding = false;
|
|
318
412
|
}
|
|
319
413
|
/** An empty list's landing: the standing row where one is drawn, else the add chip. */
|
|
320
414
|
function focusEmpty(): void {
|
|
321
|
-
(onStanding
|
|
415
|
+
if (onStanding) focusRow(standingId);
|
|
416
|
+
else addEl?.focus();
|
|
322
417
|
}
|
|
323
418
|
/** Splice `value` in at `at` under a fresh id and commit it. Every reshape withdraws
|
|
324
419
|
* the editor's standing undo offer: a restore reinserts at the index its removal left,
|
|
325
420
|
* which a reshape moves (`undo.svelte.ts`). */
|
|
326
421
|
function insertAt(at: number, value: unknown): string {
|
|
422
|
+
const before = snapshot();
|
|
327
423
|
undo.withdraw();
|
|
328
424
|
const id = seq.next();
|
|
329
425
|
ids = [...ids.slice(0, at), id, ...ids.slice(at)];
|
|
330
426
|
const next = arr.slice();
|
|
331
427
|
next.splice(at, 0, value);
|
|
332
428
|
onCommit(next);
|
|
429
|
+
record(before, next, { id });
|
|
333
430
|
return id;
|
|
334
431
|
}
|
|
335
432
|
|
|
336
433
|
function commitElement(k: number, next: unknown): void {
|
|
337
|
-
if (onStanding) {
|
|
434
|
+
if (onStanding || (pending && k === ids.length)) {
|
|
338
435
|
if (next === undefined || cellBlank(next)) return;
|
|
339
436
|
claimStanding();
|
|
437
|
+
} else if (next === undefined && control === 'number') {
|
|
438
|
+
// The focus follows only where the row still held it: a change on leaving is
|
|
439
|
+
// a focus already on its way elsewhere.
|
|
440
|
+
const held = !!rowEls[ids[k]]?.contains(document.activeElement);
|
|
441
|
+
return remove(k, { offer: true, land: held });
|
|
340
442
|
}
|
|
341
443
|
const copy = arr.slice();
|
|
342
444
|
// A cleared element control commits `undefined` (the unset rung), but an
|
|
@@ -357,10 +459,11 @@
|
|
|
357
459
|
if (control === 'object' && !table) open.add(id);
|
|
358
460
|
void focusAfterFlush(id, column);
|
|
359
461
|
}
|
|
360
|
-
/** Element `k` as `row` and `below` as new elements after it, one commit: a paste
|
|
361
|
-
* several lines into a row, each line past the first a row as Enter would
|
|
362
|
-
* The caret ends where the
|
|
363
|
-
function spill(k: number, row: Content, below: Content[]): void {
|
|
462
|
+
/** Element `k` as `row` and `below` as new elements after it, one commit: a paste or
|
|
463
|
+
* a drop of several lines into a row, each line past the first a row as Enter would
|
|
464
|
+
* open it. The caret ends where the lines do, at `caret` in the last. */
|
|
465
|
+
function spill(k: number, row: Content, below: Content[], caret: number): void {
|
|
466
|
+
const before = onStanding ? undefined : snapshot();
|
|
364
467
|
if (onStanding) claimStanding();
|
|
365
468
|
undo.withdraw();
|
|
366
469
|
const at = k + 1;
|
|
@@ -370,13 +473,48 @@
|
|
|
370
473
|
next[k] = row;
|
|
371
474
|
next.splice(at, 0, ...below);
|
|
372
475
|
onCommit(next);
|
|
476
|
+
if (before) record(before, next, { id: fresh.at(-1)!, caret });
|
|
477
|
+
void (async () => {
|
|
478
|
+
if (!(await span.resumes(tick()))) return;
|
|
479
|
+
els[fresh.at(-1)!]?.setCaret?.(caret);
|
|
480
|
+
})();
|
|
481
|
+
}
|
|
482
|
+
/** Element `upper + 1` joined onto the end of element `upper`, one commit, the caret
|
|
483
|
+
* landing between the two: Backspace at a prose line's start, Delete at its end.
|
|
484
|
+
* Whether it joined: not past either end of the list, nor where a leaf is held or
|
|
485
|
+
* the joined line would pass the cap. */
|
|
486
|
+
function join(upper: number): boolean {
|
|
487
|
+
if (upper < 0 || upper + 1 >= ids.length) return false;
|
|
488
|
+
const tail = els[ids[upper + 1]]?.current?.();
|
|
489
|
+
const joined = tail && els[ids[upper]]?.appended?.(tail);
|
|
490
|
+
if (!joined) return false;
|
|
491
|
+
const before = snapshot();
|
|
492
|
+
undo.withdraw();
|
|
493
|
+
const [kept, gone] = [ids[upper], ids[upper + 1]];
|
|
494
|
+
ids = ids.filter((_, i) => i !== upper + 1);
|
|
495
|
+
drop(gone);
|
|
496
|
+
const next = arr.slice();
|
|
497
|
+
next.splice(upper, 2, joined.content);
|
|
498
|
+
onCommit(next);
|
|
499
|
+
record(before, next, { id: kept, caret: joined.caret });
|
|
373
500
|
void (async () => {
|
|
374
501
|
if (!(await span.resumes(tick()))) return;
|
|
375
|
-
els[
|
|
502
|
+
els[kept]?.setCaret?.(joined.caret);
|
|
376
503
|
})();
|
|
504
|
+
return true;
|
|
505
|
+
}
|
|
506
|
+
/** Enter in a number row once it holds a number moves on, as Enter on a line does:
|
|
507
|
+
* to the row below with its number selected, or after the last to the standing row. */
|
|
508
|
+
function numberEntered(k: number): void {
|
|
509
|
+
if (k >= ids.length - 1) return add();
|
|
510
|
+
focusRow(ids[k + 1]);
|
|
511
|
+
rowEls[ids[k + 1]]?.querySelector('input')?.select();
|
|
377
512
|
}
|
|
378
513
|
function add(): void {
|
|
379
|
-
insertAfter(ids.length - 1);
|
|
514
|
+
if (control !== 'number') return insertAfter(ids.length - 1);
|
|
515
|
+
if (atCap) return;
|
|
516
|
+
adding = true;
|
|
517
|
+
void focusAfterFlush(standingId);
|
|
380
518
|
}
|
|
381
519
|
/** Remove element `k`. Focus lands on the element before it, or on the one that
|
|
382
520
|
* slid into its place; on the add affordance once the list is empty, which is then
|
|
@@ -387,25 +525,45 @@
|
|
|
387
525
|
* pinned and so keeps the clip where the pointer left it, where the first cell
|
|
388
526
|
* would scroll the box back to its start on every press. A removal the user asked for
|
|
389
527
|
* by name, the remove's press or its key, is offered back on the editor's toast
|
|
390
|
-
* (`undo.svelte.ts`); Backspace on an empty element takes nothing worth offering.
|
|
391
|
-
|
|
528
|
+
* (`undo.svelte.ts`); Backspace on an empty element takes nothing worth offering.
|
|
529
|
+
* `land` off leaves the focus where it is. The standing row after a list of numbers
|
|
530
|
+
* is no element: its remove dismisses it and writes nothing. */
|
|
531
|
+
function remove(
|
|
532
|
+
k: number,
|
|
533
|
+
{
|
|
534
|
+
column,
|
|
535
|
+
fromRemove = false,
|
|
536
|
+
offer = false,
|
|
537
|
+
land = true
|
|
538
|
+
}: { column?: string; fromRemove?: boolean; offer?: boolean; land?: boolean } = {}
|
|
539
|
+
): void {
|
|
540
|
+
if (k >= ids.length) {
|
|
541
|
+
adding = false;
|
|
542
|
+
addEl?.focus();
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const before = snapshot();
|
|
392
546
|
const dropped = ids[k];
|
|
393
547
|
const value = arr[k];
|
|
394
548
|
const name = rowName(k) ?? t.strings.elementItem(k + 1);
|
|
395
549
|
const next = ids.filter((_, i) => i !== k);
|
|
396
550
|
ids = next;
|
|
397
551
|
drop(dropped);
|
|
398
|
-
|
|
399
|
-
|
|
552
|
+
const values = arr.filter((_, i) => i !== k);
|
|
553
|
+
onCommit(values);
|
|
554
|
+
const step = record(before, values, next.length ? { id: next[Math.max(k - 1, 0)] } : undefined);
|
|
555
|
+
if (offer) undo.offer(t.strings.undoRemoved(name), () => restore(k, value, step));
|
|
400
556
|
else undo.withdraw();
|
|
557
|
+
if (!land) return;
|
|
401
558
|
void focusAfterFlush(next[Math.max(k - 1, 0)], column, fromRemove).then(() => {
|
|
402
559
|
if (offer) undo.hand(document.activeElement);
|
|
403
560
|
});
|
|
404
561
|
}
|
|
405
562
|
/** A removal's undo: `value` back at `k`, under a fresh id, focused where a landing on
|
|
406
563
|
* it would focus. A no-op once this field is gone, the row with it. */
|
|
407
|
-
function restore(k: number, value: unknown): void {
|
|
564
|
+
function restore(k: number, value: unknown, step: ListStep): void {
|
|
408
565
|
if (!span.alive) return;
|
|
566
|
+
if (history.latest() === step && takeStep(false)) return;
|
|
409
567
|
void focusAfterFlush(insertAt(Math.min(k, ids.length), value));
|
|
410
568
|
}
|
|
411
569
|
/** A collapsed record's remove key, on its summary: the remove is out of the tab order,
|
|
@@ -413,7 +571,7 @@
|
|
|
413
571
|
function onSummaryKey(e: KeyboardEvent, k: number): void {
|
|
414
572
|
if (e.key !== 'Backspace' || !(e.metaKey || e.ctrlKey) || e.shiftKey || e.altKey) return;
|
|
415
573
|
e.preventDefault();
|
|
416
|
-
remove(k,
|
|
574
|
+
remove(k, { offer: true });
|
|
417
575
|
}
|
|
418
576
|
/**
|
|
419
577
|
* Move element `k` to slot `to`: one splice of the ids and of the values together, so
|
|
@@ -423,6 +581,7 @@
|
|
|
423
581
|
*/
|
|
424
582
|
function move(k: number, to: number): void {
|
|
425
583
|
if (to === k || to < 0 || to >= ids.length) return;
|
|
584
|
+
const before = snapshot();
|
|
426
585
|
const pressed = document.activeElement;
|
|
427
586
|
undo.withdraw();
|
|
428
587
|
arm.arm();
|
|
@@ -434,12 +593,72 @@
|
|
|
434
593
|
const [v] = next.splice(k, 1);
|
|
435
594
|
next.splice(to, 0, v);
|
|
436
595
|
onCommit(next);
|
|
596
|
+
record(before, next, before.focus?.id === id ? before.focus : { id });
|
|
437
597
|
void (async () => {
|
|
438
598
|
if (!(await span.resumes(tick()))) return;
|
|
439
599
|
if (pressed instanceof HTMLElement && pressed.isConnected && rowEls[id]?.contains(pressed))
|
|
440
600
|
pressed.focus();
|
|
441
601
|
})();
|
|
442
602
|
}
|
|
603
|
+
// ── The list's own undo (`listhistory.ts`) ───────────────────────────────────
|
|
604
|
+
const history = listHistory((a, b) =>
|
|
605
|
+
sameValues(a, b, (row) =>
|
|
606
|
+
control === 'object' && row !== null && typeof row === 'object'
|
|
607
|
+
? Object.fromEntries(Object.entries(row).filter(([, cell]) => !cellBlank(cell)))
|
|
608
|
+
: row
|
|
609
|
+
)
|
|
610
|
+
);
|
|
611
|
+
/** Where the focus is in the list: the row holding it, and a prose row's caret. */
|
|
612
|
+
function focusNow(): ListFocus | undefined {
|
|
613
|
+
const at = document.activeElement;
|
|
614
|
+
const id = ids.find((i) => rowEls[i]?.contains(at));
|
|
615
|
+
return id === undefined ? undefined : { id, caret: els[id]?.caret?.() };
|
|
616
|
+
}
|
|
617
|
+
function snapshot(): ListRows {
|
|
618
|
+
return { ids: ids.slice(), values: arr, focus: focusNow() };
|
|
619
|
+
}
|
|
620
|
+
/** Record the step from `before` to the rows just committed. Its `after` takes the
|
|
621
|
+
* rows as the store hands them back once the commit lands, which is what a later
|
|
622
|
+
* read compares against. */
|
|
623
|
+
function record(before: ListRows, values: unknown[], focus?: ListFocus): ListStep {
|
|
624
|
+
const step: ListStep = { before, after: { ids: ids.slice(), values, focus } };
|
|
625
|
+
history.record(step);
|
|
626
|
+
void (async () => {
|
|
627
|
+
if (!(await span.resumes(tick()))) return;
|
|
628
|
+
step.after = { ...step.after, values: arr };
|
|
629
|
+
})();
|
|
630
|
+
return step;
|
|
631
|
+
}
|
|
632
|
+
/** Take the latest step back (`redo` false) or forward again, and put the rows and the
|
|
633
|
+
* focus where it leaves them. Whether it did. */
|
|
634
|
+
function takeStep(redo: boolean): boolean {
|
|
635
|
+
const to = history.take(redo, arr);
|
|
636
|
+
if (!to) return false;
|
|
637
|
+
undo.withdraw();
|
|
638
|
+
for (const id of ids) if (!to.ids.includes(id)) drop(id);
|
|
639
|
+
ids = to.ids.slice();
|
|
640
|
+
onCommit(to.values);
|
|
641
|
+
const focus = to.focus && ids.includes(to.focus.id) ? to.focus : undefined;
|
|
642
|
+
void (async () => {
|
|
643
|
+
if (!(await span.resumes(tick()))) return;
|
|
644
|
+
const caret = focus?.caret;
|
|
645
|
+
const row = focus && els[focus.id];
|
|
646
|
+
if (caret !== undefined && row?.setCaret) row.setCaret(caret);
|
|
647
|
+
else void focusAfterFlush(focus?.id);
|
|
648
|
+
})();
|
|
649
|
+
return true;
|
|
650
|
+
}
|
|
651
|
+
/** The list's chords anywhere in it, ahead of the control's own: the nearest list
|
|
652
|
+
* answers, never the one around a nested list. */
|
|
653
|
+
function onUndoChord(e: KeyboardEvent): void {
|
|
654
|
+
const chord = undoChord(e);
|
|
655
|
+
if (!chord) return;
|
|
656
|
+
if (!(e.target instanceof Element) || e.target.closest('.qm-array') !== e.currentTarget) return;
|
|
657
|
+
if (drag.held() || !takeStep(chord === 'redo')) return;
|
|
658
|
+
e.preventDefault();
|
|
659
|
+
e.stopPropagation();
|
|
660
|
+
}
|
|
661
|
+
|
|
443
662
|
/** Take the caret: the first element, or the add affordance when the list is empty;
|
|
444
663
|
* which is then the only thing there is to land on, and the next thing the user
|
|
445
664
|
* wants anyway. Reached by a label click and by the editor's landing verbs, which
|
|
@@ -448,7 +667,7 @@
|
|
|
448
667
|
if (ids.length === 0) return focusEmpty();
|
|
449
668
|
if (table) return void cellEls[ids[0]]?.focus();
|
|
450
669
|
if (control === 'object') return focusObjectRow(ids[0]);
|
|
451
|
-
|
|
670
|
+
focusRow(ids[0]);
|
|
452
671
|
}
|
|
453
672
|
/** An object row's landing: inside the subform when that row is the open one, on
|
|
454
673
|
* the row's own summary otherwise — a collapsed row's control is its summary. */
|
|
@@ -507,12 +726,8 @@
|
|
|
507
726
|
})();
|
|
508
727
|
}
|
|
509
728
|
const el = els[id];
|
|
510
|
-
if (
|
|
511
|
-
|
|
512
|
-
return undefined;
|
|
513
|
-
}
|
|
514
|
-
if (pos != null && el.setCaret) el.setCaret(pos);
|
|
515
|
-
else el.focus();
|
|
729
|
+
if (pos != null && el?.setCaret) el.setCaret(pos);
|
|
730
|
+
else focusRow(id);
|
|
516
731
|
return rowEls[id];
|
|
517
732
|
}
|
|
518
733
|
/** Focus element `id` after the flush, never in the same tick: a mutation commits
|
|
@@ -543,7 +758,7 @@
|
|
|
543
758
|
return;
|
|
544
759
|
}
|
|
545
760
|
if (control === 'object') return focusObjectRow(id);
|
|
546
|
-
|
|
761
|
+
focusRow(id);
|
|
547
762
|
}
|
|
548
763
|
/** Whether a cell's committed value is at its blank: unset, the empty string, or a
|
|
549
764
|
* `Content` with no characters. A boolean or a number is never blank. */
|
|
@@ -605,16 +820,17 @@
|
|
|
605
820
|
// the emptiness test reads the state before this keystroke applies; so the
|
|
606
821
|
// press that empties an element never also removes it.
|
|
607
822
|
e.preventDefault();
|
|
608
|
-
remove(k, column);
|
|
823
|
+
remove(k, { column });
|
|
609
824
|
}
|
|
610
825
|
}
|
|
611
|
-
/** The reorder's
|
|
612
|
-
*
|
|
613
|
-
* row answers,
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
* release. */
|
|
826
|
+
/** The reorder's key, on the row so it answers from the summary, from any cell the
|
|
827
|
+
* row holds and from its remove: Alt+↑/↓, the table island's own binding. The nearest
|
|
828
|
+
* row answers, so a key in a nested list's row moves that row and never the record
|
|
829
|
+
* around it. A control that takes the chord keeps it: a listbox opens on it and a
|
|
830
|
+
* date segment steps, and their rows move from the remove. The standing row is no
|
|
831
|
+
* element and moves nowhere. A held drag owns the row until its release. */
|
|
617
832
|
function onRowKey(e: KeyboardEvent, k: number): void {
|
|
833
|
+
if (k >= ids.length) return;
|
|
618
834
|
if (!e.altKey || e.shiftKey || e.ctrlKey || e.metaKey || e.isComposing || drag.held()) return;
|
|
619
835
|
// A cell that took the key — a select opening, a date segment stepping, a prose
|
|
620
836
|
// leaf joining — owns it.
|
|
@@ -631,7 +847,18 @@
|
|
|
631
847
|
const drag = rowDrag({
|
|
632
848
|
count: () => ids.length,
|
|
633
849
|
box: (i) => rowEls[ids[i]]?.getBoundingClientRect(),
|
|
634
|
-
move
|
|
850
|
+
move: (k, to) => {
|
|
851
|
+
const id = ids[k];
|
|
852
|
+
move(k, to);
|
|
853
|
+
// The row's summary takes the focus, so the keys that move it or take the move
|
|
854
|
+
// back act on the row the pointer just moved.
|
|
855
|
+
void (async () => {
|
|
856
|
+
if (!(await span.resumes(tick()))) return;
|
|
857
|
+
const summary = rowEls[id]?.querySelector<HTMLElement>('.qm-element-summary');
|
|
858
|
+
if (summary && !rowEls[id]?.contains(document.activeElement))
|
|
859
|
+
summary.focus({ preventScroll: true });
|
|
860
|
+
})();
|
|
861
|
+
}
|
|
635
862
|
});
|
|
636
863
|
onDestroy(drag.release);
|
|
637
864
|
|
|
@@ -660,6 +887,7 @@
|
|
|
660
887
|
<div
|
|
661
888
|
class={['qm-array', { empty: ids.length === 0 }]}
|
|
662
889
|
role="group"
|
|
890
|
+
onkeydowncapture={onUndoChord}
|
|
663
891
|
aria-labelledby={label != null ? labelId : undefined}
|
|
664
892
|
aria-describedby={description ? descriptionId : undefined}
|
|
665
893
|
>
|
|
@@ -716,16 +944,19 @@
|
|
|
716
944
|
label={fieldTitle(key, sub)}
|
|
717
945
|
descriptionId={idBase != null ? propertyDomIds(idBase, key).description : undefined}
|
|
718
946
|
description={sub.description}
|
|
947
|
+
brief={false}
|
|
719
948
|
/>
|
|
720
949
|
</div>
|
|
721
950
|
{/each}
|
|
722
951
|
<span class="qm-array-table-head-end"></span>
|
|
723
952
|
</div>
|
|
724
953
|
{#each ids as id, k (id)}
|
|
954
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
725
955
|
<div
|
|
726
956
|
class="qm-array-row qm-array-table-row qm-wash"
|
|
727
957
|
data-qm-index={k}
|
|
728
958
|
bind:this={rowEls[id]}
|
|
959
|
+
onkeydown={(e) => onRowKey(e, k)}
|
|
729
960
|
>
|
|
730
961
|
<ObjectField
|
|
731
962
|
bare
|
|
@@ -738,6 +969,7 @@
|
|
|
738
969
|
onCommit={(obj) => commitElement(k, obj)}
|
|
739
970
|
onCellKey={(e, column) => onElementKey(e, k, column)}
|
|
740
971
|
diagnostics={routed.below.get(k)}
|
|
972
|
+
review={innerReview(k)}
|
|
741
973
|
/>
|
|
742
974
|
{@render removeButton(k, true)}
|
|
743
975
|
</div>
|
|
@@ -785,6 +1017,9 @@
|
|
|
785
1017
|
same rung as a panel header's, so the surface has one disclosure. -->
|
|
786
1018
|
<Icon name="chevron-right" class="qm-el-chevron" size={CHEVRON} />
|
|
787
1019
|
<span class="qm-element-title">{t.strings.elementItem(k + 1)}</span>
|
|
1020
|
+
{#if !open.has(id) && preview(k)}
|
|
1021
|
+
<span class="qm-element-preview">{preview(k)}</span>
|
|
1022
|
+
{/if}
|
|
788
1023
|
</button>
|
|
789
1024
|
<div class="qm-row-actions">
|
|
790
1025
|
{@render removeButton(k)}
|
|
@@ -800,11 +1035,14 @@
|
|
|
800
1035
|
contentAt={(path) => readAt([k, ...path])}
|
|
801
1036
|
onCommit={(obj) => commitElement(k, obj)}
|
|
802
1037
|
diagnostics={routed.below.get(k)}
|
|
1038
|
+
review={innerReview(k)}
|
|
803
1039
|
/>
|
|
1040
|
+
<ReviewRows entries={ownReview(k)} value={arr[k]} member />
|
|
804
1041
|
{:else}
|
|
805
1042
|
<!-- A collapsed row draws no cell, so what its cells would have said is said
|
|
806
1043
|
under the head, where the row can be seen: the message names the leaf. -->
|
|
807
1044
|
<DiagnosticList diagnostics={routed.below.get(k)?.map((d) => d.diagnostic)} />
|
|
1045
|
+
<ReviewRows entries={rowReview(k)} value={arr[k]} member />
|
|
808
1046
|
{/if}
|
|
809
1047
|
</div>
|
|
810
1048
|
{/each}
|
|
@@ -816,10 +1054,12 @@
|
|
|
816
1054
|
bind:this={rowsEl}
|
|
817
1055
|
>
|
|
818
1056
|
{#each rowIds as id, k (id)}
|
|
1057
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
819
1058
|
<div
|
|
820
1059
|
class={['qm-array-row qm-wash', { standing: id === standingId }]}
|
|
821
1060
|
data-qm-index={k}
|
|
822
1061
|
bind:this={rowEls[id]}
|
|
1062
|
+
onkeydown={(e) => onRowKey(e, k)}
|
|
823
1063
|
>
|
|
824
1064
|
{#if control === 'prose'}
|
|
825
1065
|
<ProseValue
|
|
@@ -829,54 +1069,94 @@
|
|
|
829
1069
|
plaintext={items != null && literalText(items)}
|
|
830
1070
|
cap={textCap(items)}
|
|
831
1071
|
label={rowName(k)}
|
|
1072
|
+
placeholder={id === standingId ? t.strings.arrayStanding : undefined}
|
|
832
1073
|
onChange={(rt) => commitElement(k, rt)}
|
|
833
1074
|
lines={{
|
|
834
1075
|
room: () => (max == null ? Infinity : max - Math.max(arr.length, 1)),
|
|
835
|
-
onLines: (rt, below) => spill(k, rt, below)
|
|
1076
|
+
onLines: (rt, below, caret) => spill(k, rt, below, caret),
|
|
1077
|
+
onJoin: (dir) => join(dir < 0 ? k - 1 : k)
|
|
836
1078
|
}}
|
|
837
1079
|
onKey={(e) => onElementKey(e, k)}
|
|
838
1080
|
/>
|
|
1081
|
+
{:else if control === 'number'}
|
|
1082
|
+
<NumberField
|
|
1083
|
+
value={arr[k] as number | undefined}
|
|
1084
|
+
integer={items != null && baseType(items) === 'integer'}
|
|
1085
|
+
placeholder={id === standingId ? t.strings.arrayStanding : undefined}
|
|
1086
|
+
label={rowName(k)}
|
|
1087
|
+
onCommit={(v) => commitElement(k, v)}
|
|
1088
|
+
onEnter={() => numberEntered(k)}
|
|
1089
|
+
/>
|
|
1090
|
+
{:else if control === 'enum'}
|
|
1091
|
+
<!-- The blank is an element's empty answer, drawn as an unanswered one. -->
|
|
1092
|
+
<EnumField
|
|
1093
|
+
value={(arr[k] as string | undefined) || undefined}
|
|
1094
|
+
values={items?.values ?? []}
|
|
1095
|
+
blankTitle={items?.ui?.blank_title}
|
|
1096
|
+
label={rowName(k)}
|
|
1097
|
+
onCommit={(v) => commitElement(k, v)}
|
|
1098
|
+
/>
|
|
1099
|
+
{:else if control === 'boolean'}
|
|
1100
|
+
<BooleanField
|
|
1101
|
+
value={renderedBoolean(arr[k])}
|
|
1102
|
+
label={rowName(k)}
|
|
1103
|
+
onCommit={(v) => commitElement(k, v)}
|
|
1104
|
+
/>
|
|
1105
|
+
{:else if control === 'date'}
|
|
1106
|
+
<DateField
|
|
1107
|
+
bind:this={els[id]}
|
|
1108
|
+
value={(arr[k] as string | undefined) || undefined}
|
|
1109
|
+
datetime={items != null && baseType(items) === 'datetime'}
|
|
1110
|
+
label={rowName(k)}
|
|
1111
|
+
onCommit={(v) => commitElement(k, v)}
|
|
1112
|
+
/>
|
|
839
1113
|
{:else}
|
|
840
1114
|
<TextField
|
|
841
1115
|
bind:this={els[id]}
|
|
842
1116
|
value={String(arr[k] ?? '')}
|
|
1117
|
+
placeholder={id === standingId ? t.strings.arrayStanding : undefined}
|
|
843
1118
|
label={rowName(k)}
|
|
844
1119
|
onCommit={(v) => commitElement(k, v)}
|
|
845
1120
|
onKey={(e) => onElementKey(e, k)}
|
|
846
1121
|
/>
|
|
847
1122
|
{/if}
|
|
848
|
-
{#if id !== standingId}
|
|
1123
|
+
{#if id !== standingId || pending}
|
|
849
1124
|
<div class="qm-row-actions">
|
|
850
|
-
{@render removeButton(k)}
|
|
1125
|
+
{@render removeButton(k, scalar)}
|
|
851
1126
|
</div>
|
|
852
1127
|
{/if}
|
|
853
1128
|
<DiagnosticList diagnostics={routed.below.get(k)?.map((d) => d.diagnostic)} />
|
|
1129
|
+
<ReviewRows entries={rowReview(k)} value={arr[k]} member />
|
|
854
1130
|
</div>
|
|
855
1131
|
{/each}
|
|
856
1132
|
</div>
|
|
857
1133
|
{/if}
|
|
858
1134
|
<DiagnosticList diagnostics={foot} />
|
|
1135
|
+
<ReviewRows entries={reviewFoot} value={arr} member />
|
|
859
1136
|
</div>
|
|
860
1137
|
|
|
861
1138
|
<!-- The remove, one button wherever a row ends: a scalar row's slab, a record row's
|
|
862
1139
|
slab after its reorder pair, a table row's last track. Out of the tab order where the
|
|
863
1140
|
row has a key that removes it: Backspace on an emptied line, ⌘/Ctrl+Backspace on a
|
|
864
|
-
record's summary. A table's filled row has none,
|
|
1141
|
+
record's summary. A table's filled row has none, nor has a scalar element's, so its
|
|
1142
|
+
remove stays a stop. -->
|
|
865
1143
|
{#snippet removeButton(k: number, stop = false)}
|
|
866
1144
|
<button
|
|
867
1145
|
type="button"
|
|
868
1146
|
class="qm-icon-btn qm-row-btn qm-remove qm-focus-ring"
|
|
869
1147
|
title={t.strings.arrayRemove}
|
|
870
1148
|
aria-label={rowAction(t.strings.arrayRemove, k)}
|
|
1149
|
+
aria-keyshortcuts={control === 'object' && !table ? undefined : 'Alt+ArrowUp Alt+ArrowDown'}
|
|
871
1150
|
tabindex={stop ? undefined : -1}
|
|
872
|
-
onclick={() => remove(k,
|
|
1151
|
+
onclick={() => remove(k, { fromRemove: true, offer: true })}><Icon name="x" /></button
|
|
873
1152
|
>
|
|
874
1153
|
{/snippet}
|
|
875
1154
|
|
|
876
1155
|
<!-- An `object` row's drag handle, a table grip's twin hung off the row's start edge.
|
|
877
1156
|
Pointer-only and out of the accessibility tree: a press on it does nothing, so a
|
|
878
1157
|
button there would be one a screen reader activates to no effect. Its twin is
|
|
879
|
-
Alt+↑/↓ from anywhere in the row, which the summary announces
|
|
1158
|
+
Alt+↑/↓ from anywhere in the row, which the summary announces, as a table's or a
|
|
1159
|
+
line's remove does for its own row. -->
|
|
880
1160
|
{#snippet handle(k: number)}
|
|
881
1161
|
<span
|
|
882
1162
|
class="qm-row-handle"
|
|
@@ -907,6 +1187,11 @@
|
|
|
907
1187
|
justify-content: space-between;
|
|
908
1188
|
gap: var(--_qm-space-2);
|
|
909
1189
|
}
|
|
1190
|
+
/* Under a label that carries its description in flow, the chip keeps the label's
|
|
1191
|
+
line rather than centring on the two. */
|
|
1192
|
+
.qm-array-header:has(> :global(.qm-field-label-row.briefed)) {
|
|
1193
|
+
align-items: baseline;
|
|
1194
|
+
}
|
|
910
1195
|
.qm-array-add-slot {
|
|
911
1196
|
display: inline-flex;
|
|
912
1197
|
align-items: center;
|
|
@@ -944,8 +1229,13 @@
|
|
|
944
1229
|
color: var(--_qm-ink-default);
|
|
945
1230
|
}
|
|
946
1231
|
/* A row that is not an element yet: the box a row draws, at the muted rung until it
|
|
947
|
-
holds the caret, and its first keystroke makes it one.
|
|
948
|
-
|
|
1232
|
+
holds the caret, and its first keystroke makes it one. A row whose control ghosts
|
|
1233
|
+
words says so in them instead, at the label rung, which a muted box would take
|
|
1234
|
+
under 3:1. */
|
|
1235
|
+
.qm-array-row.standing
|
|
1236
|
+
> :global(
|
|
1237
|
+
:is(.qm-input, .qm-control-box):not(:has(.qm-prose-placeholder), :placeholder-shown)
|
|
1238
|
+
) {
|
|
949
1239
|
opacity: var(--_qm-opacity-muted);
|
|
950
1240
|
transition: opacity var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
951
1241
|
}
|
|
@@ -976,7 +1266,9 @@
|
|
|
976
1266
|
component's. The longhand beats the family's `padding` shorthand without a
|
|
977
1267
|
specificity fight: `controls.css` ranks the family at zero inside `:where()`. */
|
|
978
1268
|
.qm-array-row > :global(.qm-input),
|
|
979
|
-
.qm-array-row > :global(.qm-control-box)
|
|
1269
|
+
.qm-array-row > :global(.qm-control-box),
|
|
1270
|
+
.qm-array-row > :global(.qm-select-wrap > .qm-control-box),
|
|
1271
|
+
.qm-array-row > :global(.qm-date-wrap .qm-control-box) {
|
|
980
1272
|
padding-inline-end: var(--_qm-tap-min);
|
|
981
1273
|
}
|
|
982
1274
|
.qm-element-summary {
|
|
@@ -1169,6 +1461,20 @@
|
|
|
1169
1461
|
color: var(--_qm-ink);
|
|
1170
1462
|
font-variant-numeric: tabular-nums;
|
|
1171
1463
|
}
|
|
1464
|
+
/* What the closed record holds, after its name and a rung under it: the label ink,
|
|
1465
|
+
on the line's remainder, and the first to give way where the line runs short. */
|
|
1466
|
+
.qm-element-preview {
|
|
1467
|
+
flex: 1 1 0;
|
|
1468
|
+
min-width: 0;
|
|
1469
|
+
overflow: hidden;
|
|
1470
|
+
text-overflow: ellipsis;
|
|
1471
|
+
white-space: nowrap;
|
|
1472
|
+
text-align: start;
|
|
1473
|
+
color: var(--_qm-ink-label);
|
|
1474
|
+
}
|
|
1475
|
+
.qm-element-summary:has(.qm-element-preview) > .qm-element-title {
|
|
1476
|
+
flex-shrink: 0;
|
|
1477
|
+
}
|
|
1172
1478
|
/* ── A table ────────────────────────────────────────────────────────────────
|
|
1173
1479
|
Every row of it is open, so it stands where an open row's subform stands: a rung
|
|
1174
1480
|
inside the field, behind the subform's vertical and between its caps (`ObjectField`,
|