@quillmark/svelte 0.35.1 → 0.37.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 +30 -18
- package/THEMING.md +1 -1
- package/dist/core/address.d.ts +5 -0
- package/dist/core/address.js +14 -0
- package/dist/core/codec/decode.d.ts +4 -2
- package/dist/core/codec/decode.js +5 -2
- package/dist/core/codec/field.d.ts +42 -16
- package/dist/core/codec/field.js +97 -28
- package/dist/core/codec/index.d.ts +8 -5
- package/dist/core/codec/index.js +4 -5
- package/dist/core/codec/prose.css +25 -81
- package/dist/core/codec/review.d.ts +31 -26
- package/dist/core/codec/review.js +93 -169
- package/dist/core/codec/schema.d.ts +12 -2
- package/dist/core/codec/schema.js +27 -5
- package/dist/core/codec/shortcuts.d.ts +5 -4
- package/dist/core/codec/shortcuts.js +9 -8
- package/dist/core/codec/table-view.js +15 -3
- package/dist/core/codec/value-diff.d.ts +21 -0
- package/dist/core/codec/value-diff.js +83 -0
- package/dist/core/codec/value-plan.d.ts +29 -0
- package/dist/core/codec/value-plan.js +157 -0
- package/dist/core/theme.css +46 -15
- package/dist/core/tooltip.css +49 -0
- package/dist/core/tooltip.d.ts +6 -0
- package/dist/core/tooltip.js +176 -0
- package/dist/preview/Preview.svelte +22 -1
- package/dist/preview/controller.js +38 -0
- package/dist/preview/strings.d.ts +2 -0
- package/dist/preview/strings.js +1 -0
- package/dist/visual/ArrayField.svelte +374 -96
- package/dist/visual/Card.svelte +33 -12
- package/dist/visual/Card.svelte.d.ts +3 -0
- package/dist/visual/CardControls.svelte +3 -3
- package/dist/visual/DateField.svelte +47 -5
- package/dist/visual/DiagnosticList.svelte +3 -2
- package/dist/visual/EnumField.svelte +20 -5
- package/dist/visual/EnumField.svelte.d.ts +5 -0
- package/dist/visual/Field.svelte +56 -47
- package/dist/visual/FieldHint.svelte +20 -8
- package/dist/visual/FormatPopover.svelte +54 -20
- package/dist/visual/MatrixField.svelte +48 -6
- package/dist/visual/MatrixField.svelte.d.ts +5 -0
- package/dist/visual/NumberField.svelte +131 -6
- package/dist/visual/NumberField.svelte.d.ts +5 -0
- package/dist/visual/ObjectField.svelte +60 -18
- package/dist/visual/ProseField.svelte +21 -5
- package/dist/visual/ProseField.svelte.d.ts +5 -1
- package/dist/visual/ProseValue.svelte +49 -8
- package/dist/visual/ProseValue.svelte.d.ts +7 -1
- package/dist/visual/ReviewCard.svelte +400 -0
- package/dist/visual/ReviewCard.svelte.d.ts +20 -0
- package/dist/visual/ReviewProposal.svelte +98 -138
- package/dist/visual/ReviewProposal.svelte.d.ts +3 -6
- package/dist/visual/ReviewRows.svelte +6 -25
- package/dist/visual/ReviewRows.svelte.d.ts +1 -3
- package/dist/visual/SlashMenu.svelte +1 -0
- package/dist/visual/TipsCard.svelte +1 -1
- package/dist/visual/VariantField.svelte +45 -4
- package/dist/visual/VariantField.svelte.d.ts +5 -0
- package/dist/visual/VisualEditor.svelte +24 -9
- package/dist/visual/VisualEditor.svelte.d.ts +8 -1
- package/dist/visual/VisualEditorInner.svelte +917 -280
- package/dist/visual/VisualEditorInner.svelte.d.ts +8 -1
- package/dist/visual/controls.css +2 -2
- package/dist/visual/index.d.ts +2 -2
- package/dist/visual/proposals.d.ts +25 -24
- package/dist/visual/proposals.js +92 -32
- package/dist/visual/props.d.ts +18 -18
- package/dist/visual/review-order.d.ts +51 -0
- package/dist/visual/review-order.js +87 -0
- package/dist/visual/review.d.ts +94 -3
- package/dist/visual/review.js +37 -2
- package/dist/visual/review.svelte.d.ts +77 -20
- package/dist/visual/review.svelte.js +306 -49
- package/dist/visual/strings.d.ts +59 -25
- package/dist/visual/strings.js +90 -29
- package/dist/visual/structure.d.ts +17 -3
- package/dist/visual/structure.js +71 -5
- package/dist/visual/undo.svelte.d.ts +3 -1
- package/dist/visual/undo.svelte.js +7 -3
- package/package.json +2 -2
package/dist/visual/Card.svelte
CHANGED
|
@@ -58,6 +58,9 @@
|
|
|
58
58
|
/** Every field in this card registers its landing handle here, which is what the
|
|
59
59
|
* editor's `focusField`/`setCaret` resolve a `DocPath` to. */
|
|
60
60
|
leaves?: LeafRegistry;
|
|
61
|
+
/** Words the header carries beside its controls, as a review's tag on a card it would
|
|
62
|
+
* take out. */
|
|
63
|
+
tag?: string;
|
|
61
64
|
}
|
|
62
65
|
let {
|
|
63
66
|
card,
|
|
@@ -72,7 +75,8 @@
|
|
|
72
75
|
onCaretMove,
|
|
73
76
|
onChange,
|
|
74
77
|
onError,
|
|
75
|
-
leaves
|
|
78
|
+
leaves,
|
|
79
|
+
tag
|
|
76
80
|
}: Props = $props();
|
|
77
81
|
|
|
78
82
|
const reviewing = review();
|
|
@@ -81,6 +85,12 @@
|
|
|
81
85
|
// title because a re-derive mid-edit hands `card` back with the title it stored.
|
|
82
86
|
let draft = $state<string | undefined>(undefined);
|
|
83
87
|
const shownTitle = $derived(draft ?? card.titleOverride);
|
|
88
|
+
/** What names the card to assistive tech: its section, and its title input after the
|
|
89
|
+
* input's own word. The stored title, never the rename in flight, so no name changes
|
|
90
|
+
* under the reader typing it. */
|
|
91
|
+
const named = $derived(
|
|
92
|
+
card.unschemable ? humanize(card.kind) : card.titleOverride.trim() || card.titlePlaceholder
|
|
93
|
+
);
|
|
84
94
|
|
|
85
95
|
// A focus the shell hands over (`focusHeader`) is not armed for replacement: the key
|
|
86
96
|
// that pressed a delete, pressed again, would retitle the card it landed on.
|
|
@@ -217,11 +227,14 @@
|
|
|
217
227
|
({@link FieldHint}): a surface portals to `[data-qm-root]`, so the card is not its
|
|
218
228
|
ancestor and nothing else marks the box its guidance belongs in. Its value is the card's
|
|
219
229
|
kind, `main` for the main card, which is the one schema-named hook a host's stylesheet
|
|
220
|
-
is promised (THEMING §"What a stylesheet may aim at").
|
|
230
|
+
is promised (THEMING §"What a stylesheet may aim at"). Named, the section is a region,
|
|
231
|
+
so a reader moving by landmark hears each card by the title its header shows; `main`
|
|
232
|
+
shows none and stays the unnamed form the regions follow. -->
|
|
221
233
|
<section
|
|
222
234
|
bind:this={el}
|
|
223
235
|
class={['qm-card', { 'qm-main': card.isMain, 'qm-unschemable': card.unschemable }]}
|
|
224
236
|
data-qm-card={card.kind}
|
|
237
|
+
aria-label={card.isMain ? undefined : named}
|
|
225
238
|
>
|
|
226
239
|
{#if card.unschemable}
|
|
227
240
|
{@render recoveryShell()}
|
|
@@ -235,7 +248,7 @@
|
|
|
235
248
|
class="qm-card-title qm-focus-ring"
|
|
236
249
|
value={shownTitle}
|
|
237
250
|
placeholder={card.titlePlaceholder}
|
|
238
|
-
aria-label={t.strings.cardTitle}
|
|
251
|
+
aria-label={t.strings.cardAction(t.strings.cardTitle, named)}
|
|
239
252
|
size="1"
|
|
240
253
|
onmousedown={onTitleMousedown}
|
|
241
254
|
onfocus={onTitleFocus}
|
|
@@ -246,6 +259,7 @@
|
|
|
246
259
|
</span>
|
|
247
260
|
</div>
|
|
248
261
|
<div class="qm-card-header-right">
|
|
262
|
+
{#if tag}<span class="qm-card-tag">{tag}</span>{/if}
|
|
249
263
|
<CardControls
|
|
250
264
|
{isFirst}
|
|
251
265
|
{isLast}
|
|
@@ -408,6 +422,7 @@
|
|
|
408
422
|
<header class="qm-card-header">
|
|
409
423
|
<span class="qm-card-title-static">{humanize(card.kind)}</span>
|
|
410
424
|
<div class="qm-card-header-right">
|
|
425
|
+
{#if tag}<span class="qm-card-tag">{tag}</span>{/if}
|
|
411
426
|
<CardControls
|
|
412
427
|
{isFirst}
|
|
413
428
|
{isLast}
|
|
@@ -426,6 +441,7 @@
|
|
|
426
441
|
<label class="qm-recovery-retype">
|
|
427
442
|
{t.strings.retypeLabel}
|
|
428
443
|
<select
|
|
444
|
+
class="qm-control-box qm-focus-ring"
|
|
429
445
|
onchange={(e) => {
|
|
430
446
|
const el = e.currentTarget as HTMLSelectElement;
|
|
431
447
|
if (el.value) ops.retype(el.value);
|
|
@@ -494,6 +510,11 @@
|
|
|
494
510
|
padding-inline: var(--_qm-column);
|
|
495
511
|
margin-block: calc(-1 * var(--_qm-space-3) / 2);
|
|
496
512
|
}
|
|
513
|
+
.qm-card-tag {
|
|
514
|
+
font-size: var(--_qm-text-label);
|
|
515
|
+
font-weight: var(--_qm-weight-mid);
|
|
516
|
+
color: var(--_qm-ink-label);
|
|
517
|
+
}
|
|
497
518
|
.qm-card-header-right {
|
|
498
519
|
display: flex;
|
|
499
520
|
align-items: center;
|
|
@@ -866,14 +887,14 @@
|
|
|
866
887
|
font-size: var(--_qm-text-label);
|
|
867
888
|
color: var(--_qm-ink-label);
|
|
868
889
|
}
|
|
869
|
-
/*
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
890
|
+
/* Forced colours drop a plane's tone, so a card draws its edge, and the placeholder's
|
|
891
|
+
GrayText would read the automatic title as disabled. */
|
|
892
|
+
@media (forced-colors: active) {
|
|
893
|
+
.qm-card {
|
|
894
|
+
border: var(--_qm-border-width) solid CanvasText;
|
|
895
|
+
}
|
|
896
|
+
.qm-card-title::placeholder {
|
|
897
|
+
color: CanvasText;
|
|
898
|
+
}
|
|
878
899
|
}
|
|
879
900
|
</style>
|
|
@@ -34,6 +34,9 @@ interface Props {
|
|
|
34
34
|
/** Every field in this card registers its landing handle here, which is what the
|
|
35
35
|
* editor's `focusField`/`setCaret` resolve a `DocPath` to. */
|
|
36
36
|
leaves?: LeafRegistry;
|
|
37
|
+
/** Words the header carries beside its controls, as a review's tag on a card it would
|
|
38
|
+
* take out. */
|
|
39
|
+
tag?: string;
|
|
37
40
|
}
|
|
38
41
|
declare const Card: import("svelte").Component<Props, {
|
|
39
42
|
revealLeaf: (key: string) => void;
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<button
|
|
37
37
|
type="button"
|
|
38
38
|
class="qm-chip qm-focus-ring"
|
|
39
|
-
|
|
39
|
+
data-qm-tip={t.strings.cardMoveUp}
|
|
40
40
|
aria-label={t.strings.cardAction(t.strings.cardMoveUp, name)}
|
|
41
41
|
aria-disabled={isFirst || undefined}
|
|
42
42
|
tabindex={isFirst ? -1 : undefined}
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
<button
|
|
46
46
|
type="button"
|
|
47
47
|
class="qm-chip qm-focus-ring"
|
|
48
|
-
|
|
48
|
+
data-qm-tip={t.strings.cardMoveDown}
|
|
49
49
|
aria-label={t.strings.cardAction(t.strings.cardMoveDown, name)}
|
|
50
50
|
aria-disabled={isLast || undefined}
|
|
51
51
|
tabindex={isLast ? -1 : undefined}
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
<button
|
|
56
56
|
type="button"
|
|
57
57
|
class="qm-chip qm-card-delete qm-focus-ring"
|
|
58
|
-
|
|
58
|
+
data-qm-tip={t.strings.cardDelete}
|
|
59
59
|
aria-label={t.strings.cardAction(t.strings.cardDelete, name)}
|
|
60
60
|
onclick={onDelete}><Icon name="trash-2" /></button
|
|
61
61
|
>
|
|
@@ -61,6 +61,13 @@
|
|
|
61
61
|
focus. Leaving with a segment filled puts the stored date back; a field storing no
|
|
62
62
|
date puts its segments back by remounting the primitive, which re-reads an unchanged
|
|
63
63
|
empty value as nothing to sync.
|
|
64
|
+
|
|
65
|
+
The field is one Tab stop (INVARIANTS §"A date field is one Tab stop"). The primitive
|
|
66
|
+
makes every segment a stop, so each is drawn through its `child` snippet, which is where
|
|
67
|
+
a `tabindex` outranks the primitive's own: the stop is the segment the focus is on, the
|
|
68
|
+
first while the focus is elsewhere, and Tab from any of them leaves the field. The
|
|
69
|
+
arrows walk the segments, the primitive's own keys, and one step past the last onto the
|
|
70
|
+
Today toggle and back, so the toggle is out of the tab order and still under the keys.
|
|
64
71
|
-->
|
|
65
72
|
<script lang="ts">
|
|
66
73
|
import { flushSync } from 'svelte';
|
|
@@ -110,13 +117,21 @@
|
|
|
110
117
|
let { value, fallback, label, labelledBy, describedBy, datetime, onCommit }: Props = $props();
|
|
111
118
|
|
|
112
119
|
let wrapEl: HTMLElement | undefined = $state();
|
|
120
|
+
let todayEl: HTMLButtonElement | undefined = $state();
|
|
121
|
+
/** The segments that take the focus. `literal` is the separator between them: present,
|
|
122
|
+
* never focusable. */
|
|
123
|
+
const segmentEls = (): HTMLElement[] => [
|
|
124
|
+
...(wrapEl?.querySelectorAll<HTMLElement>('[data-segment]:not([data-segment="literal"])') ?? [])
|
|
125
|
+
];
|
|
113
126
|
/** Take the caret: what the label click, and a parent placing focus here, calls.
|
|
114
127
|
* The first segment, not the field: focus lives on a segment (which is why the
|
|
115
|
-
* ring is `.qm-focus-ring-within`), and the container holds none.
|
|
116
|
-
* separator between segments: present, never focusable. */
|
|
128
|
+
* ring is `.qm-focus-ring-within`), and the container holds none. */
|
|
117
129
|
export function focus(): void {
|
|
118
|
-
|
|
130
|
+
segmentEls()[0]?.focus();
|
|
119
131
|
}
|
|
132
|
+
/** The field's one Tab stop while the focus is inside: a segment by its part, or the
|
|
133
|
+
* toggle as {@link TODAY}. Unset, the stop is the first segment. */
|
|
134
|
+
let stop = $state<string | undefined>(undefined);
|
|
120
135
|
|
|
121
136
|
/** The part of a stored string this control edits: all of a `datetime`, and the date
|
|
122
137
|
* half of a `date`, anything past `YYYY-MM-DD` being no part of its type. */
|
|
@@ -196,8 +211,23 @@
|
|
|
196
211
|
/** Focus moving between segments is neither an entry nor a leaving. */
|
|
197
212
|
const within = (e: FocusEvent): boolean => !!wrapEl?.contains(e.relatedTarget as Node | null);
|
|
198
213
|
function enter(e: FocusEvent): void {
|
|
214
|
+
stop = (e.target as HTMLElement).dataset.segment ?? TODAY;
|
|
199
215
|
if (!within(e) && value == null && fallbackDate) seat = true;
|
|
200
216
|
}
|
|
217
|
+
/** One step past the last segment is the toggle, and one step back returns. */
|
|
218
|
+
function step(e: KeyboardEvent): void {
|
|
219
|
+
if (!todayEl || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
|
|
220
|
+
const last = segmentEls().at(-1);
|
|
221
|
+
const to =
|
|
222
|
+
e.key === 'ArrowRight' && e.target === last
|
|
223
|
+
? todayEl
|
|
224
|
+
: e.key === 'ArrowLeft' && e.target === todayEl
|
|
225
|
+
? last
|
|
226
|
+
: undefined;
|
|
227
|
+
if (!to) return;
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
to.focus();
|
|
230
|
+
}
|
|
201
231
|
const filled = (): boolean =>
|
|
202
232
|
[...(wrapEl?.querySelectorAll('[data-segment]') ?? [])].some(
|
|
203
233
|
(s) => s.getAttribute('data-segment') !== 'literal' && !s.hasAttribute('data-ghosted')
|
|
@@ -209,6 +239,7 @@
|
|
|
209
239
|
}
|
|
210
240
|
function leave(e: FocusEvent): void {
|
|
211
241
|
if (within(e)) return;
|
|
242
|
+
stop = undefined;
|
|
212
243
|
const seated = seat;
|
|
213
244
|
seat = false;
|
|
214
245
|
const emptied = held;
|
|
@@ -314,13 +345,17 @@
|
|
|
314
345
|
aria-describedby={describedBy}
|
|
315
346
|
data-ghosted={ghost ? '' : undefined}
|
|
316
347
|
data-default={seated || follows ? '' : undefined}
|
|
317
|
-
onkeydown={
|
|
348
|
+
onkeydown={(e: KeyboardEvent) => {
|
|
349
|
+
settle();
|
|
350
|
+
step(e);
|
|
351
|
+
}}
|
|
318
352
|
>
|
|
319
353
|
{#snippet children({ segments })}
|
|
320
354
|
<!-- Keyed by index: `part` repeats (the `literal` separators between
|
|
321
355
|
segments all carry it) so a part-keyed block collides. -->
|
|
322
356
|
{@const hour = segments.find((seg) => seg.part === 'hour')?.value}
|
|
323
357
|
{@const twelve = segments.some((seg) => seg.part === 'dayPeriod')}
|
|
358
|
+
{@const first = segments.find((seg) => seg.part !== 'literal')?.part}
|
|
324
359
|
{#each segments as seg, i (i)}
|
|
325
360
|
{@const shown = segmentText(seg.part, seg.value, hour, twelve)}
|
|
326
361
|
<BitsDateField.Segment
|
|
@@ -328,7 +363,11 @@
|
|
|
328
363
|
part={seg.part}
|
|
329
364
|
data-ghosted={shown.ghosted}
|
|
330
365
|
>
|
|
331
|
-
{
|
|
366
|
+
{#snippet child({ props })}
|
|
367
|
+
{@const roving =
|
|
368
|
+
seg.part === 'literal' ? {} : { tabindex: seg.part === (stop ?? first) ? 0 : -1 }}
|
|
369
|
+
<span {...props} {...roving}>{shown.text}</span>
|
|
370
|
+
{/snippet}
|
|
332
371
|
</BitsDateField.Segment>
|
|
333
372
|
{/each}
|
|
334
373
|
{#if unread}
|
|
@@ -338,7 +377,10 @@
|
|
|
338
377
|
<button
|
|
339
378
|
type="button"
|
|
340
379
|
class="qm-chip qm-tap-floor qm-focus-ring qm-date-today"
|
|
380
|
+
bind:this={todayEl}
|
|
381
|
+
tabindex={stop === TODAY ? 0 : -1}
|
|
341
382
|
aria-pressed={!!follows}
|
|
383
|
+
aria-keyshortcuts="T"
|
|
342
384
|
data-default={follows === 'default' ? '' : undefined}
|
|
343
385
|
onclick={toggle}
|
|
344
386
|
>
|
|
@@ -56,8 +56,9 @@
|
|
|
56
56
|
</script>
|
|
57
57
|
|
|
58
58
|
{#if diagnostics && diagnostics.length}
|
|
59
|
-
<!--
|
|
60
|
-
|
|
59
|
+
<!-- Not a live region: the list arrives with its text in it, so the editor's standing
|
|
60
|
+
region says it (INVARIANTS §Diagnostics). -->
|
|
61
|
+
<div class="qm-diag-list" id={listId} {@attach markInvalid}>
|
|
61
62
|
{#each diagnostics as d, i (i)}
|
|
62
63
|
<span class="qm-diag-line">{diagnosticText(d, t.formatDiagnostic, t.strings)}</span>
|
|
63
64
|
{/each}
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
/** `<label for>` target. Set → the label names this trigger, so `aria-label`
|
|
38
38
|
* comes off: two names is where implementations disagree about which wins. */
|
|
39
39
|
id?: string;
|
|
40
|
+
/** The field's label element, which names the list as `label` does where it is unset. */
|
|
41
|
+
labelledBy?: string;
|
|
40
42
|
/** The parked `description` (FieldLabel): announced after the name. */
|
|
41
43
|
describedBy?: string;
|
|
42
44
|
onCommit: (v: string | undefined) => void;
|
|
@@ -45,6 +47,9 @@
|
|
|
45
47
|
optionAllowed?: (value: string) => boolean;
|
|
46
48
|
/** How a refused option draws: greyed and unpickable, or left out of the list. */
|
|
47
49
|
enumDisallowed?: 'hide' | 'disable';
|
|
50
|
+
/** `value` is a proposal's, not the document's: the list marks it, and every pick
|
|
51
|
+
* commits, the proposed member's included, so a pick answers the proposal. */
|
|
52
|
+
proposing?: boolean;
|
|
48
53
|
}
|
|
49
54
|
let {
|
|
50
55
|
value,
|
|
@@ -54,16 +59,20 @@
|
|
|
54
59
|
optional = false,
|
|
55
60
|
label,
|
|
56
61
|
id,
|
|
62
|
+
labelledBy,
|
|
57
63
|
describedBy,
|
|
58
64
|
onCommit,
|
|
59
65
|
optionAllowed,
|
|
60
|
-
enumDisallowed = 'disable'
|
|
66
|
+
enumDisallowed = 'disable',
|
|
67
|
+
proposing = false
|
|
61
68
|
}: Props = $props();
|
|
62
69
|
|
|
63
70
|
// The sentinel's option value: a namespaced marker that no schema-authored
|
|
64
71
|
// enum member would ever be (`values` are classification markings, seal ids, and
|
|
65
72
|
// the like), so it never collides with a real option.
|
|
66
73
|
const UNSET = '__qm_unset__';
|
|
74
|
+
/** What the primitive holds while a proposal stands: no option, so every pick changes it. */
|
|
75
|
+
const PROPOSED = '__qm_proposed__';
|
|
67
76
|
|
|
68
77
|
// Driven controlled (`value` + `onValueChange`, never `bind:`) so reconciliation
|
|
69
78
|
// stays the package's rather than the primitive's.
|
|
@@ -99,9 +108,9 @@
|
|
|
99
108
|
<Select.Root
|
|
100
109
|
type="single"
|
|
101
110
|
allowDeselect={false}
|
|
102
|
-
value={local}
|
|
111
|
+
value={proposing ? PROPOSED : local}
|
|
103
112
|
onValueChange={(v) => {
|
|
104
|
-
if (v == null) return;
|
|
113
|
+
if (v == null || v === PROPOSED) return;
|
|
105
114
|
local = v;
|
|
106
115
|
// Sentinel → unset (parent `removeField`, default renders); any real pick
|
|
107
116
|
// (incl. the default value) → a genuine write.
|
|
@@ -119,7 +128,13 @@
|
|
|
119
128
|
<Icon name="chevron-down" class="qm-select-chevron" />
|
|
120
129
|
</Select.Trigger>
|
|
121
130
|
<Select.Portal to={portalTarget}>
|
|
122
|
-
<Select.Content
|
|
131
|
+
<Select.Content
|
|
132
|
+
collisionBoundary={portalTarget ?? []}
|
|
133
|
+
strategy="absolute"
|
|
134
|
+
sideOffset={spacePx(wrapEl)}
|
|
135
|
+
aria-labelledby={labelledBy}
|
|
136
|
+
aria-label={labelledBy ? undefined : label}
|
|
137
|
+
>
|
|
123
138
|
<!-- The list portals out of the trigger's DOM but into the nearest
|
|
124
139
|
`[data-qm-root]`, and carries the marker itself, like FormatPopover.
|
|
125
140
|
That root is the boundary a flip is measured against too, being the box
|
|
@@ -160,7 +175,7 @@
|
|
|
160
175
|
<!-- The reset is the sentinel, offered once there is something to reset:
|
|
161
176
|
unset, the list's check already stands where a reset would land. -->
|
|
162
177
|
{#if !unset}
|
|
163
|
-
<div class="qm-select-divider"
|
|
178
|
+
<div class="qm-select-divider" aria-hidden="true"></div>
|
|
164
179
|
<Select.Item
|
|
165
180
|
class="qm-menu-item qm-select-item qm-select-unset"
|
|
166
181
|
value={UNSET}
|
|
@@ -16,6 +16,8 @@ interface Props {
|
|
|
16
16
|
/** `<label for>` target. Set → the label names this trigger, so `aria-label`
|
|
17
17
|
* comes off: two names is where implementations disagree about which wins. */
|
|
18
18
|
id?: string;
|
|
19
|
+
/** The field's label element, which names the list as `label` does where it is unset. */
|
|
20
|
+
labelledBy?: string;
|
|
19
21
|
/** The parked `description` (FieldLabel): announced after the name. */
|
|
20
22
|
describedBy?: string;
|
|
21
23
|
onCommit: (v: string | undefined) => void;
|
|
@@ -24,6 +26,9 @@ interface Props {
|
|
|
24
26
|
optionAllowed?: (value: string) => boolean;
|
|
25
27
|
/** How a refused option draws: greyed and unpickable, or left out of the list. */
|
|
26
28
|
enumDisallowed?: 'hide' | 'disable';
|
|
29
|
+
/** `value` is a proposal's, not the document's: the list marks it, and every pick
|
|
30
|
+
* commits, the proposed member's included, so a pick answers the proposal. */
|
|
31
|
+
proposing?: boolean;
|
|
27
32
|
}
|
|
28
33
|
declare const EnumField: import("svelte").Component<Props, {}, "">;
|
|
29
34
|
type EnumField = ReturnType<typeof EnumField>;
|
package/dist/visual/Field.svelte
CHANGED
|
@@ -60,8 +60,7 @@
|
|
|
60
60
|
import ReviewProposal from './ReviewProposal.svelte';
|
|
61
61
|
import ReviewRows from './ReviewRows.svelte';
|
|
62
62
|
import { review } from './review.svelte.js';
|
|
63
|
-
import {
|
|
64
|
-
import { keydownHandler } from 'prosemirror-keymap';
|
|
63
|
+
import { numberProposal, shownValue, textProposal } from './review.js';
|
|
65
64
|
|
|
66
65
|
interface Props {
|
|
67
66
|
field: FieldModel;
|
|
@@ -147,8 +146,14 @@
|
|
|
147
146
|
// resolves to digits, and the control has to know it follows the render date.
|
|
148
147
|
const declared = $derived(printedText(field.schema.default));
|
|
149
148
|
const optional = $derived(optionalCell(field.schema));
|
|
149
|
+
// A proposal is drawn in the control. The focus arriving in the control makes it current, as
|
|
150
|
+
// the caret arriving in a leaf's words makes theirs.
|
|
151
|
+
const reviewing = review();
|
|
152
|
+
const reviewed = $derived(reviewing.at(leafKey));
|
|
153
|
+
const proposed = $derived(reviewed.proposed);
|
|
150
154
|
// Where the field stands against its default, for the label row's end (`FieldLabel`):
|
|
151
|
-
// unset with the default printing, or written over one that would. A
|
|
155
|
+
// unset with the default printing, or written over one that would. A proposal standing on
|
|
156
|
+
// the field says the value it would hold, so the default goes unsaid meanwhile. A container's
|
|
152
157
|
// source is its cells' composed, so only a control holding one value says either.
|
|
153
158
|
const scalar = $derived(!isContainer(field.control));
|
|
154
159
|
// A prose leaf commits past the derive (`VisualEditorInner` `proseChanged`), so its
|
|
@@ -159,7 +164,7 @@
|
|
|
159
164
|
since && since.row === provenance ? since.written : provenance?.source === 'authored'
|
|
160
165
|
);
|
|
161
166
|
const defaulted = $derived(
|
|
162
|
-
scalar && !written && provenance?.source === 'default' && printed !== undefined
|
|
167
|
+
scalar && !written && provenance?.source === 'default' && printed !== undefined && !proposed
|
|
163
168
|
);
|
|
164
169
|
const resettable = $derived(scalar && written && declared !== undefined);
|
|
165
170
|
const defaultId = $derived(`${domIds.control}-default`);
|
|
@@ -318,33 +323,29 @@
|
|
|
318
323
|
* rather than counted twice.
|
|
319
324
|
*/
|
|
320
325
|
// ── Review: this field's own items (`review.svelte.ts`) ──────────────────────
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
+
/** A whole proposed value drawn as words over the control's own: a leaf of lines' as a word
|
|
327
|
+
* diff, carried onto what the reader wrote since its writer read it, a number's as the struck
|
|
328
|
+
* and the proposed figures. */
|
|
329
|
+
const texted = $derived(
|
|
330
|
+
field.control === 'prose' && (field.inline || field.plaintext)
|
|
331
|
+
? textProposal(proposed, printed ? (ghost as Content) : undefined)
|
|
332
|
+
: undefined
|
|
333
|
+
);
|
|
334
|
+
const numbered = $derived(field.control === 'number' ? numberProposal(proposed) : undefined);
|
|
335
|
+
const worded = $derived(texted ?? numbered);
|
|
336
|
+
/** What a control that cannot draw a proposal as words shows while one stands: the value
|
|
337
|
+
* Accept would write, tinted (`ReviewProposal`), or its default or empty face where Accept
|
|
338
|
+
* clears it. */
|
|
339
|
+
const display = $derived(proposed && !worded ? shownValue(proposed, value) : value);
|
|
340
|
+
/** A commit on a control that shows one value answers the proposal on it: the proposed value
|
|
341
|
+
* accepts it, any other dismisses it (INVARIANTS §Review). */
|
|
342
|
+
function answerOrCommit(v: unknown): void {
|
|
343
|
+
if (proposed && reviewing.answerWith(proposed.id, v)) return;
|
|
344
|
+
onCommitScalar(v);
|
|
345
|
+
}
|
|
326
346
|
/** The items naming a place inside this field: a record's and a list's own controls draw
|
|
327
347
|
* them where they are, any other's under this one. */
|
|
328
348
|
const nestedReview = $derived(reviewed.nested);
|
|
329
|
-
/** The chords, with the focus anywhere in the field: the proposal's answers. A prose leaf's
|
|
330
|
-
* own items answer first, in the leaf. */
|
|
331
|
-
const reviewKeys = keydownHandler({
|
|
332
|
-
[REVIEW_KEYS.accept]: () => {
|
|
333
|
-
if (!proposed) return false;
|
|
334
|
-
reviewing.act(proposed.id, 'accept', true);
|
|
335
|
-
return true;
|
|
336
|
-
},
|
|
337
|
-
[REVIEW_KEYS.dismiss]: () => {
|
|
338
|
-
if (!proposed) return false;
|
|
339
|
-
reviewing.act(proposed.id, 'dismiss', true);
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
function onReviewKey(e: KeyboardEvent): void {
|
|
344
|
-
if (e.defaultPrevented || !proposed) return;
|
|
345
|
-
// The bindings read no view: this is `prosemirror-keymap`'s chord matcher alone.
|
|
346
|
-
if (reviewKeys({} as never, e)) e.preventDefault();
|
|
347
|
-
}
|
|
348
349
|
|
|
349
350
|
const reportFocus = $derived(
|
|
350
351
|
field.control === 'prose'
|
|
@@ -354,9 +355,7 @@
|
|
|
354
355
|
);
|
|
355
356
|
</script>
|
|
356
357
|
|
|
357
|
-
|
|
358
|
-
<!-- The keydown is a control's, bubbled: the field answers the review chords for it. -->
|
|
359
|
-
<div class={['qm-field', { cell: span === 'cell' }]} data-tail={tail} onkeydown={onReviewKey}>
|
|
358
|
+
<div class={['qm-field', { cell: span === 'cell' }]} data-tail={tail}>
|
|
360
359
|
{#if !ownsLabel && !headed}
|
|
361
360
|
<FieldLabel
|
|
362
361
|
label={field.label}
|
|
@@ -377,14 +376,14 @@
|
|
|
377
376
|
rule below holds why). One markup for both spans; a field owning its row nests a
|
|
378
377
|
level and measures the same. -->
|
|
379
378
|
<div class="qm-field-stack">
|
|
379
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
380
380
|
<div
|
|
381
381
|
class="qm-field-control qm-wash"
|
|
382
382
|
{@attach registerControl}
|
|
383
383
|
onfocusin={(e) => {
|
|
384
384
|
reportFocus?.(e);
|
|
385
|
-
if (proposed) reviewing.point(proposed.id
|
|
385
|
+
if (proposed) reviewing.point(proposed.id);
|
|
386
386
|
}}
|
|
387
|
-
onfocusout={() => proposed && reviewing.point(undefined, 'caret', leafKey)}
|
|
388
387
|
>
|
|
389
388
|
{#if field.control === 'prose'}
|
|
390
389
|
<ProseField
|
|
@@ -394,14 +393,16 @@
|
|
|
394
393
|
{addr}
|
|
395
394
|
inline={field.inline}
|
|
396
395
|
plaintext={field.plaintext}
|
|
396
|
+
paragraphs={field.paragraphs}
|
|
397
397
|
fallback={printed ? (ghost as Content) : undefined}
|
|
398
|
-
placeholder={none}
|
|
398
|
+
placeholder={proposed ? undefined : none}
|
|
399
399
|
emptyUnsets={optional}
|
|
400
400
|
labelledBy={domIds.label}
|
|
401
401
|
describedBy={proseDescribedBy}
|
|
402
402
|
defaultNoteId={defaultId}
|
|
403
403
|
cap={cap && { ...cap, onCount: (n) => (chars = n) }}
|
|
404
404
|
{leafKey}
|
|
405
|
+
proposed={texted}
|
|
405
406
|
{onFocus}
|
|
406
407
|
{onCaretMove}
|
|
407
408
|
onChange={proseCommitted}
|
|
@@ -411,21 +412,23 @@
|
|
|
411
412
|
/>
|
|
412
413
|
{:else if field.control === 'enum'}
|
|
413
414
|
<EnumField
|
|
414
|
-
value={
|
|
415
|
+
value={display as string | undefined}
|
|
415
416
|
values={field.schema.values ?? []}
|
|
416
417
|
fallback={(ghost as string | undefined) ?? declared}
|
|
417
418
|
blankTitle={field.schema.ui?.blank_title}
|
|
418
419
|
{optional}
|
|
419
420
|
id={domIds.control}
|
|
421
|
+
labelledBy={domIds.label}
|
|
420
422
|
{describedBy}
|
|
421
|
-
onCommit={
|
|
423
|
+
onCommit={answerOrCommit}
|
|
424
|
+
proposing={!!proposed}
|
|
422
425
|
{optionAllowed}
|
|
423
426
|
{enumDisallowed}
|
|
424
427
|
/>
|
|
425
428
|
{:else if field.control === 'variant'}
|
|
426
429
|
<VariantField
|
|
427
430
|
bind:this={variantEl}
|
|
428
|
-
value={
|
|
431
|
+
value={display as Record<string, unknown> | undefined}
|
|
429
432
|
schema={field.schema}
|
|
430
433
|
{ghostMember}
|
|
431
434
|
label={field.label}
|
|
@@ -437,10 +440,12 @@
|
|
|
437
440
|
{optionAllowed}
|
|
438
441
|
{enumDisallowed}
|
|
439
442
|
diagnostics={deep}
|
|
443
|
+
review={nestedReview}
|
|
440
444
|
/>
|
|
441
445
|
{:else if field.control === 'number'}
|
|
442
446
|
<NumberField
|
|
443
|
-
value={
|
|
447
|
+
value={display as number | undefined}
|
|
448
|
+
proposed={numbered}
|
|
444
449
|
integer={baseType(field.schema) === 'integer'}
|
|
445
450
|
fallback={declared}
|
|
446
451
|
placeholder={none}
|
|
@@ -450,22 +455,22 @@
|
|
|
450
455
|
/>
|
|
451
456
|
{:else if field.control === 'boolean'}
|
|
452
457
|
<BooleanField
|
|
453
|
-
value={renderedBoolean(
|
|
458
|
+
value={renderedBoolean(display)}
|
|
454
459
|
fallback={ghost as boolean | undefined}
|
|
455
460
|
{optional}
|
|
456
461
|
id={domIds.control}
|
|
457
462
|
{describedBy}
|
|
458
|
-
onCommit={
|
|
463
|
+
onCommit={answerOrCommit}
|
|
459
464
|
/>
|
|
460
465
|
{:else if field.control === 'date'}
|
|
461
466
|
<DateField
|
|
462
467
|
bind:this={dateEl}
|
|
463
|
-
value={
|
|
468
|
+
value={display as string | undefined}
|
|
464
469
|
fallback={stringifyGhost(field.schema.default)}
|
|
465
470
|
datetime={baseType(field.schema) === 'datetime'}
|
|
466
471
|
labelledBy={domIds.label}
|
|
467
472
|
{describedBy}
|
|
468
|
-
onCommit={
|
|
473
|
+
onCommit={answerOrCommit}
|
|
469
474
|
/>
|
|
470
475
|
{:else if field.control === 'array'}
|
|
471
476
|
<ArrayField
|
|
@@ -514,10 +519,11 @@
|
|
|
514
519
|
{contentAt}
|
|
515
520
|
onCommit={onCommitScalar}
|
|
516
521
|
diagnostics={deep}
|
|
522
|
+
review={nestedReview}
|
|
517
523
|
/>
|
|
518
524
|
{:else}
|
|
519
525
|
<TextField
|
|
520
|
-
value={
|
|
526
|
+
value={display as string | undefined}
|
|
521
527
|
fallback={declared}
|
|
522
528
|
placeholder={none}
|
|
523
529
|
id={domIds.control}
|
|
@@ -527,11 +533,14 @@
|
|
|
527
533
|
{/if}
|
|
528
534
|
</div>
|
|
529
535
|
|
|
530
|
-
{#if field.control
|
|
531
|
-
<ReviewRows entries={nestedReview}
|
|
536
|
+
{#if !isContainer(field.control)}
|
|
537
|
+
<ReviewRows entries={nestedReview} />
|
|
532
538
|
{/if}
|
|
533
|
-
{#if proposed}
|
|
534
|
-
<ReviewProposal
|
|
539
|
+
{#if proposed && !worded}
|
|
540
|
+
<ReviewProposal
|
|
541
|
+
item={proposed}
|
|
542
|
+
current={value ?? ghost ?? (field.control === 'boolean' ? false : undefined)}
|
|
543
|
+
/>
|
|
535
544
|
{/if}
|
|
536
545
|
{#if scalar}
|
|
537
546
|
<DiagnosticList {diagnostics} />
|