@quillmark/svelte 0.30.0 → 0.32.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 +5 -5
- package/dist/core/address.d.ts +1 -1
- package/dist/core/address.js +1 -1
- package/dist/core/codec/atoms.js +1 -1
- package/dist/core/codec/breaks.js +3 -2
- package/dist/core/codec/decode.d.ts +4 -3
- package/dist/core/codec/decode.js +17 -13
- package/dist/core/codec/field.d.ts +5 -4
- package/dist/core/codec/field.js +139 -49
- package/dist/core/codec/index.d.ts +2 -0
- package/dist/core/codec/index.js +5 -1
- package/dist/core/codec/inputrules.js +3 -3
- package/dist/core/codec/islands.d.ts +1 -1
- package/dist/core/codec/islands.js +3 -3
- package/dist/core/codec/keymap.d.ts +1 -1
- package/dist/core/codec/keymap.js +3 -2
- package/dist/core/codec/list-move.js +2 -1
- package/dist/core/codec/list-paste.js +1 -1
- package/dist/core/codec/lists.d.ts +1 -1
- package/dist/core/codec/lists.js +7 -6
- package/dist/core/codec/markdown-paste.js +2 -2
- package/dist/core/codec/positions.d.ts +12 -1
- package/dist/core/codec/prose.css +3 -11
- package/dist/core/codec/schema.d.ts +3 -3
- package/dist/core/codec/schema.js +6 -6
- package/dist/core/codec/shortcuts.d.ts +91 -0
- package/dist/core/codec/shortcuts.js +135 -0
- package/dist/core/codec/slash.d.ts +4 -2
- package/dist/core/codec/slash.js +11 -1
- package/dist/core/codec/table-paste.js +1 -1
- package/dist/core/codec/table-view.d.ts +1 -1
- package/dist/core/codec/table-view.js +27 -37
- package/dist/core/codec/tasks.js +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/theme.css +16 -8
- package/dist/preset/scale.css +1 -1
- package/dist/preview/Preview.svelte +2 -3
- package/dist/preview/bridge.js +2 -2
- package/dist/preview/geometry.d.ts +2 -2
- package/dist/preview/geometry.js +2 -2
- package/dist/preview/paint.js +1 -1
- package/dist/visual/ArrayField.svelte +172 -87
- package/dist/visual/BooleanField.svelte +3 -3
- package/dist/visual/Card.svelte +68 -47
- package/dist/visual/CardControls.svelte +1 -1
- package/dist/visual/DateField.svelte +17 -2
- package/dist/visual/DiagnosticList.svelte +35 -3
- package/dist/visual/EnumField.svelte +59 -45
- package/dist/visual/Field.svelte +16 -6
- package/dist/visual/Field.svelte.d.ts +3 -1
- package/dist/visual/FieldHint.svelte +10 -3
- package/dist/visual/FormatPopover.svelte +9 -3
- package/dist/visual/MatrixAdd.svelte +4 -19
- package/dist/visual/MatrixField.svelte +21 -13
- package/dist/visual/NumberField.svelte +2 -3
- package/dist/visual/ObjectField.svelte +166 -147
- package/dist/visual/ProseField.svelte +8 -3
- package/dist/visual/SlashMenu.svelte +24 -12
- package/dist/visual/SlashMenu.svelte.d.ts +2 -0
- package/dist/visual/TextField.svelte +1 -1
- package/dist/visual/VariantField.svelte +1 -1
- package/dist/visual/VisualEditor.svelte +1 -1
- package/dist/visual/VisualEditor.svelte.d.ts +1 -1
- package/dist/visual/VisualEditorInner.svelte +159 -24
- package/dist/visual/VisualEditorInner.svelte.d.ts +1 -1
- package/dist/visual/controls.css +43 -5
- package/dist/visual/diagnostics.d.ts +2 -2
- package/dist/visual/diagnostics.js +2 -2
- package/dist/visual/index.d.ts +2 -0
- package/dist/visual/index.js +3 -0
- package/dist/visual/leaves.js +1 -1
- package/dist/visual/props.d.ts +2 -2
- package/dist/visual/strings.d.ts +33 -15
- package/dist/visual/strings.js +42 -7
- package/dist/visual/structure.d.ts +27 -18
- package/dist/visual/structure.js +32 -28
- package/dist/visual/tips.js +1 -1
- package/dist/visual/undo.svelte.d.ts +36 -0
- package/dist/visual/undo.svelte.js +119 -0
- package/package.json +2 -2
- package/dist/visual/hold.d.ts +0 -17
- package/dist/visual/hold.js +0 -39
package/dist/visual/Card.svelte
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import type { LeafRegistry } from './leaves.js';
|
|
17
17
|
import type { CardModel, FieldModel } from './structure.js';
|
|
18
18
|
import { placeFields, humanize, initialExpandedGroup, kindTitle, mountKey } from './structure.js';
|
|
19
|
-
import {
|
|
19
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
20
20
|
import type { FieldDomIds } from './domid.js';
|
|
21
21
|
import Field from './Field.svelte';
|
|
22
22
|
import FieldHint from './FieldHint.svelte';
|
|
@@ -134,43 +134,39 @@
|
|
|
134
134
|
// the width, and the card's gap counts the block twice besides.
|
|
135
135
|
const hasMeta = $derived(ungrouped.length > 0 || grouped.length > 0);
|
|
136
136
|
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
// group stays where it still
|
|
137
|
+
// The open panels, seeded once from the card's shape: the first is open on mount.
|
|
138
|
+
// Card is keyed by stable id, so the set survives the VisualEditor re-derive that
|
|
139
|
+
// reassigns `card` and resets only on a remount. Not reconciled to later section
|
|
140
|
+
// changes: a retype is the one reshape, and an open group stays open where it still
|
|
141
|
+
// exists.
|
|
141
142
|
// svelte-ignore state_referenced_locally
|
|
142
|
-
|
|
143
|
+
const first = initialExpandedGroup(card.sections);
|
|
144
|
+
const open = new SvelteSet<string>(first == null ? [] : [first]);
|
|
143
145
|
let headers = $state<Record<string, HTMLButtonElement | undefined>>({});
|
|
144
146
|
let panels = $state<Record<string, HTMLElement | undefined>>({});
|
|
145
|
-
/** Whether the panels animate the move
|
|
147
|
+
/** Whether the panels animate the move about to happen. False for a reveal
|
|
146
148
|
* ({@link revealLeaf}), restored by the header gesture the motion is there for, so its
|
|
147
149
|
* return needs no timer. */
|
|
148
150
|
let animate = $state(true);
|
|
149
151
|
/**
|
|
150
|
-
*
|
|
151
|
-
* held still focused, and `inert` does not say where focus should go
|
|
152
|
-
* drops it on the body
|
|
153
|
-
* reopens the section.
|
|
154
|
-
*
|
|
152
|
+
* Open or close one panel; the others stay as they are. A closing panel goes `inert`
|
|
153
|
+
* with whatever it held still focused, and `inert` does not say where focus should go
|
|
154
|
+
* (the browser drops it on the body), so the close hands focus to the header, which is
|
|
155
|
+
* what reopens the section. Nothing above the header moves, so the header stays where
|
|
156
|
+
* it was pressed.
|
|
155
157
|
*/
|
|
156
|
-
function setExpanded(next: string | null): void {
|
|
157
|
-
const closing = expanded;
|
|
158
|
-
if (closing !== null && closing !== next && panels[closing]?.contains(document.activeElement))
|
|
159
|
-
headers[closing]?.focus();
|
|
160
|
-
expanded = next;
|
|
161
|
-
}
|
|
162
|
-
/** The header is the anchor: a section closing above it is what would carry it off the
|
|
163
|
-
* fold, and a section opens under its own header (`hold.ts`). */
|
|
164
158
|
function toggleGroup(group: string): void {
|
|
165
159
|
animate = true;
|
|
166
|
-
|
|
160
|
+
if (!open.has(group)) return void open.add(group);
|
|
161
|
+
if (panels[group]?.contains(document.activeElement)) headers[group]?.focus();
|
|
162
|
+
open.delete(group);
|
|
167
163
|
}
|
|
168
164
|
|
|
169
165
|
/**
|
|
170
166
|
* Open the group holding leaf `key`: a caret placed in a collapsed panel does not
|
|
171
167
|
* land at all. `VisualEditor.setCaret` calls this on every card and then waits a
|
|
172
168
|
* flush before landing, since `inert` clears when the panel renders open, not when
|
|
173
|
-
*
|
|
169
|
+
* the set is written.
|
|
174
170
|
*
|
|
175
171
|
* The move is instant, because that same flush is when the landing measures its target:
|
|
176
172
|
* an animating track still reads its start value there, and the trip would be computed
|
|
@@ -179,20 +175,20 @@
|
|
|
179
175
|
*
|
|
180
176
|
* A call, not a prop: a reveal is an event, and modelling it as state needs a
|
|
181
177
|
* fresh-identity wrapper to re-fire and an `untrack` to keep the per-keystroke
|
|
182
|
-
* re-derive from reopening
|
|
178
|
+
* re-derive from reopening a panel under the user.
|
|
183
179
|
*/
|
|
184
180
|
export function revealLeaf(key: string): void {
|
|
185
181
|
const section = grouped.find((s) => s.fields.some((f) => ops.leafKey(f.name) === key));
|
|
186
182
|
if (!section?.group) return;
|
|
187
183
|
animate = false;
|
|
188
|
-
|
|
184
|
+
open.add(section.group);
|
|
189
185
|
}
|
|
190
186
|
|
|
191
187
|
let el = $state<HTMLElement | undefined>(undefined);
|
|
192
188
|
/**
|
|
193
189
|
* Bring this card into view after the structure mutation that placed it: `center` for
|
|
194
190
|
* an insert, `nearest` for a reorder. The reduced-motion guard is JS rather than the
|
|
195
|
-
* CSS the
|
|
191
|
+
* CSS the panels use: a scroll's behaviour is an argument, not a transition a
|
|
196
192
|
* media query can cancel.
|
|
197
193
|
*
|
|
198
194
|
* The caller is what waits out a reorder's own trip before asking: the run holds the
|
|
@@ -266,13 +262,15 @@
|
|
|
266
262
|
</div>
|
|
267
263
|
{/each}
|
|
268
264
|
|
|
269
|
-
<!--
|
|
270
|
-
|
|
265
|
+
<!-- Each panel opens on its own. Rendered only when a card has groups, so an
|
|
266
|
+
empty stack does not stand a gap under the ungrouped fields. -->
|
|
271
267
|
{#if grouped.length}
|
|
272
268
|
<div class={['qm-groups', { 'qm-instant': !animate }]}>
|
|
273
269
|
{#each grouped as section (section.group)}
|
|
274
270
|
{@const group = section.group as string}
|
|
275
|
-
{@const isOpen =
|
|
271
|
+
{@const isOpen = open.has(group)}
|
|
272
|
+
{@const flagged =
|
|
273
|
+
!isOpen && section.fields.some((f) => ops.diagFor(f.name)?.length)}
|
|
276
274
|
{@const panelId = ops.panelId(group)}
|
|
277
275
|
{@const headIds = section.head ? ops.domIds(section.head.name) : undefined}
|
|
278
276
|
{@const headHint = section.head?.description}
|
|
@@ -295,6 +293,12 @@
|
|
|
295
293
|
class="qm-group-chevron"
|
|
296
294
|
size={CHEVRON}
|
|
297
295
|
/>{section.label}
|
|
296
|
+
{#if flagged}
|
|
297
|
+
<!-- A closed panel draws none of its fields, so what they would say is
|
|
298
|
+
marked on the header that opens them. -->
|
|
299
|
+
<span class="qm-group-flag" aria-hidden="true"></span>
|
|
300
|
+
<span class="qm-visually-hidden">{t.strings.groupFlagged}</span>
|
|
301
|
+
{/if}
|
|
298
302
|
</button>
|
|
299
303
|
{#if headIds && headHint}
|
|
300
304
|
<FieldHint
|
|
@@ -354,10 +358,11 @@
|
|
|
354
358
|
|
|
355
359
|
{#snippet sectionFields(fields: FieldModel[], head?: FieldModel)}
|
|
356
360
|
<div class="qm-fields qm-tracks">
|
|
357
|
-
{#each placeFields(fields) as { field: f, span } (mountKey(f.name, f.schema))}
|
|
361
|
+
{#each placeFields(fields) as { field: f, span, tail } (mountKey(f.name, f.schema))}
|
|
358
362
|
<Field
|
|
359
363
|
field={f}
|
|
360
364
|
{span}
|
|
365
|
+
{tail}
|
|
361
366
|
value={card.values[f.name]}
|
|
362
367
|
provenance={card.provenance[f.name]}
|
|
363
368
|
{doc}
|
|
@@ -430,7 +435,7 @@
|
|
|
430
435
|
|
|
431
436
|
<style>
|
|
432
437
|
/* An island: the card is the base plane and the column behind it the sunken one, and
|
|
433
|
-
the step between the two tones is the whole of its edge (
|
|
438
|
+
the step between the two tones is the whole of its edge (INVARIANTS §"A plane is a
|
|
434
439
|
tone"). The block half is the same rung as the gap: the payload stands that far off
|
|
435
440
|
the card's edge and off the body below it. The header insets itself to the
|
|
436
441
|
section-heading column (`.qm-card-header`). The inline half stands a step tighter
|
|
@@ -488,6 +493,14 @@
|
|
|
488
493
|
.qm-card:focus-within :global(.qm-card-controls) {
|
|
489
494
|
opacity: 1;
|
|
490
495
|
}
|
|
496
|
+
/* Without a hover there is nothing to reveal the row on but a caret, which a tap on the
|
|
497
|
+
header never places: a touch reader would find delete only by typing in the card. So
|
|
498
|
+
the row rests drawn, at the rung a live control rests at. */
|
|
499
|
+
@media (hover: none) {
|
|
500
|
+
.qm-card :global(.qm-card-controls) {
|
|
501
|
+
opacity: var(--_qm-opacity-rest);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
491
504
|
/* The rename hit region is the header's free width at full height, so a press
|
|
492
505
|
anywhere left of the controls enters the title edit. `align-self: stretch` beats the
|
|
493
506
|
header's centring, which is also what keeps the target legal with no padding: WCAG
|
|
@@ -504,15 +517,15 @@
|
|
|
504
517
|
overlaid input tracks its content width. Both carry the same nothing for a box model
|
|
505
518
|
and inherit the same type tokens, which is what makes the two measure alike.
|
|
506
519
|
|
|
507
|
-
The type is the group header's:
|
|
508
|
-
|
|
509
|
-
|
|
520
|
+
The type is a rung over the group header's: the card holds its sections, so its name
|
|
521
|
+
ranks above theirs, at the paper rung and at the header's weight: the size ramp ranks,
|
|
522
|
+
and the weight stays the chrome's one (INVARIANTS §Styling). */
|
|
510
523
|
.qm-card-title-sizer {
|
|
511
524
|
display: inline-grid;
|
|
512
525
|
align-items: center;
|
|
513
526
|
min-width: 0;
|
|
514
527
|
max-width: 100%;
|
|
515
|
-
font-size: var(--_qm-text-
|
|
528
|
+
font-size: var(--_qm-text-paper);
|
|
516
529
|
font-weight: var(--_qm-weight-mid);
|
|
517
530
|
line-height: var(--_qm-leading-tight);
|
|
518
531
|
font-family: inherit;
|
|
@@ -525,9 +538,9 @@
|
|
|
525
538
|
min-width: 2ch;
|
|
526
539
|
}
|
|
527
540
|
/* The title draws no box in any state: a card title is already the one line that
|
|
528
|
-
reads as the card's name, and the region's `cursor: text` answers the pointer.
|
|
529
|
-
|
|
530
|
-
ink
|
|
541
|
+
reads as the card's name, and the region's `cursor: text` answers the pointer. The
|
|
542
|
+
automatic title is the input's placeholder and still the card's name, so it draws at
|
|
543
|
+
the ink a typed one does: a reader names the card by it either way. */
|
|
531
544
|
.qm-card-title {
|
|
532
545
|
grid-area: 1 / 1;
|
|
533
546
|
width: 100%;
|
|
@@ -540,9 +553,8 @@
|
|
|
540
553
|
padding: 0;
|
|
541
554
|
background: transparent;
|
|
542
555
|
}
|
|
543
|
-
/* The label ink every placeholder takes rather than the UA's grey. */
|
|
544
556
|
.qm-card-title::placeholder {
|
|
545
|
-
color: var(--_qm-ink
|
|
557
|
+
color: var(--_qm-ink);
|
|
546
558
|
opacity: 1;
|
|
547
559
|
}
|
|
548
560
|
.qm-card-body {
|
|
@@ -555,7 +567,17 @@
|
|
|
555
567
|
display: flex;
|
|
556
568
|
flex-direction: column;
|
|
557
569
|
}
|
|
558
|
-
/*
|
|
570
|
+
/* The danger ink at the size a glyph's stroke reads at beside a word: a mark, not a
|
|
571
|
+
badge, so it says something under here is wrong and leaves the saying to the fields. */
|
|
572
|
+
.qm-group-flag {
|
|
573
|
+
flex-shrink: 0;
|
|
574
|
+
width: calc(2 * var(--_qm-space));
|
|
575
|
+
height: calc(2 * var(--_qm-space));
|
|
576
|
+
margin-inline-start: var(--_qm-space);
|
|
577
|
+
border-radius: var(--_qm-radius-pill);
|
|
578
|
+
background: var(--_qm-danger);
|
|
579
|
+
}
|
|
580
|
+
/* One rung between the payload's two kinds of section, and none inside the panel stack:
|
|
559
581
|
what stands one disclosure row off the next is the two headers' own block padding and
|
|
560
582
|
nothing else, so the rows tile and their targets with them. A run of one-line rows
|
|
561
583
|
wants the tighter rhythm — the `--_qm-space-3` the fields keep between their own rows
|
|
@@ -569,7 +591,7 @@
|
|
|
569
591
|
}
|
|
570
592
|
/* The card's two horizontals, and ranking is the one thing a horizontal is for: they
|
|
571
593
|
stand the payload against the title above it and the body below it, where saying what
|
|
572
|
-
sits inside what is the verticals' (
|
|
594
|
+
sits inside what is the verticals' (INVARIANTS §"A plane is a tone"). Each is
|
|
573
595
|
conditional on what it ranks against: `main` is headerless, and a card with no body
|
|
574
596
|
has nothing under the payload to divide it from.
|
|
575
597
|
|
|
@@ -584,8 +606,8 @@
|
|
|
584
606
|
.qm-meta-bottom {
|
|
585
607
|
border-bottom: var(--_qm-border-width) solid var(--_qm-border);
|
|
586
608
|
}
|
|
587
|
-
/* A section's share of the boundary between sections, one rung at each end.
|
|
588
|
-
|
|
609
|
+
/* A section's share of the boundary between sections, one rung at each end. A
|
|
610
|
+
panel spends the same rung from its header and its panel, where it also caps the
|
|
589
611
|
vertical those two edges hold.
|
|
590
612
|
|
|
591
613
|
No stroke: a vertical would mark a section a reader has no name for. The inset is
|
|
@@ -619,7 +641,7 @@
|
|
|
619
641
|
row-gap: var(--row-gap);
|
|
620
642
|
}
|
|
621
643
|
/* The nesting vertical, on the card's inset with the panel's fields one `--_qm-nest`
|
|
622
|
-
off it (
|
|
644
|
+
off it (INVARIANTS §"A plane is a tone"). The end inset is the column's, so the
|
|
623
645
|
panel's wells end where a top-level field's do. `--_qm-border` and
|
|
624
646
|
not `--_qm-accent`: the verticals and the rules beside them are one stroke at every
|
|
625
647
|
depth, and a tone that changed as it went in would read as unrelated lines rather
|
|
@@ -681,7 +703,7 @@
|
|
|
681
703
|
|
|
682
704
|
`font: inherit` because a UA button inherits no face, then the body rung, one step
|
|
683
705
|
over the field labels beneath it: at the label rung the two read as one register and
|
|
684
|
-
the
|
|
706
|
+
the panel stack stops looking like structure. Size, weight and leading sit after
|
|
685
707
|
`font`, a shorthand that carries `line-height`. */
|
|
686
708
|
.qm-group-header {
|
|
687
709
|
display: flex;
|
|
@@ -765,8 +787,7 @@
|
|
|
765
787
|
/* What a toggle moves is the panel's track, and the box's own bottom edge where the
|
|
766
788
|
last section is the one toggling. A reveal's landing measures its target one flush
|
|
767
789
|
after asking — where either, mid-flight, still reads its start value — so nothing
|
|
768
|
-
about the
|
|
769
|
-
so the opening one and the closing one above it stand still together (`revealLeaf`). */
|
|
790
|
+
about the panels animates for it (`revealLeaf`). */
|
|
770
791
|
.qm-groups.qm-instant .qm-group-panel,
|
|
771
792
|
.qm-groups.qm-instant .qm-group {
|
|
772
793
|
transition: none;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Card controls, composable cards only.
|
|
3
3
|
Right-aligned in the header: a move-up/move-down chevron pair (each disabled at its
|
|
4
4
|
edge), then delete, the row revealed while the pointer or the caret is in the card.
|
|
5
|
-
Reorder is buttons, not drag
|
|
5
|
+
Reorder is buttons, not drag. All three are chips (controls.css): fill arrives
|
|
6
6
|
on hover, and delete rests at the label ink beside them. The card scopes
|
|
7
7
|
that reveal, so its condition lives in the parent's CSS; the row keeps the narrower
|
|
8
8
|
guarantee here, that a focused control is a visible one.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
(the unset rung) where nothing is declared, the parent removing the field. The value-object a date field lowers to is a render-time
|
|
6
6
|
concern: the editor only sees the stored string.
|
|
7
7
|
|
|
8
|
-
`today` is the render date rather than a written one (
|
|
8
|
+
`today` is the render date rather than a written one (quillmark `docs/quills/quill-yaml-reference.md` §"Dated by the render"), so its
|
|
9
9
|
digits take the default rung: they print, and nothing wrote them. The digits are
|
|
10
10
|
the local date, which is what `resolve` and a session opened without a date both
|
|
11
11
|
render. The Today toggle writes `today`, and pressed, writes those digits; `T` in a
|
|
@@ -104,7 +104,8 @@
|
|
|
104
104
|
|
|
105
105
|
// The stored form may carry a time (`datetime`); the date half is what a date
|
|
106
106
|
// field edits, so anything past `YYYY-MM-DD` is not this control's. `parseDate`
|
|
107
|
-
// throws on a malformed authored value:
|
|
107
|
+
// throws on a malformed authored value: the segments stand empty and the stored
|
|
108
|
+
// string draws beside them (`unread`), so the value an error names is on screen.
|
|
108
109
|
function toDateValue(s: string): DateValue | undefined {
|
|
109
110
|
if (!s) return undefined;
|
|
110
111
|
if (s === TODAY) return renderDate;
|
|
@@ -115,6 +116,9 @@
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
const unread = $derived(
|
|
120
|
+
value && value !== TODAY && !toDateValue(value.slice(0, 10)) ? value : undefined
|
|
121
|
+
);
|
|
118
122
|
const fallbackDate = $derived(toDateValue(fallback?.slice(0, 10) ?? ''));
|
|
119
123
|
/** The default is the primitive's value: from entering an unset field until an
|
|
120
124
|
* edit or leaving. Part of the projection, so a re-derivation keeps it. */
|
|
@@ -276,6 +280,9 @@
|
|
|
276
280
|
{shown.text}
|
|
277
281
|
</BitsDateField.Segment>
|
|
278
282
|
{/each}
|
|
283
|
+
{#if unread}
|
|
284
|
+
<span class="qm-date-unread">{unread}</span>
|
|
285
|
+
{/if}
|
|
279
286
|
{#if !datetime}
|
|
280
287
|
<button
|
|
281
288
|
type="button"
|
|
@@ -348,6 +355,14 @@
|
|
|
348
355
|
the box stands as tall as the inputs beside it. Its pad sits inside the box's
|
|
349
356
|
inset, so its label ends on the column the digits start on from the other side,
|
|
350
357
|
and its fill stands about as far off the box's end as off its top and bottom. */
|
|
358
|
+
.qm-date-unread {
|
|
359
|
+
margin-inline-start: var(--_qm-space-2);
|
|
360
|
+
overflow: hidden;
|
|
361
|
+
text-overflow: ellipsis;
|
|
362
|
+
white-space: nowrap;
|
|
363
|
+
font-family: var(--_qm-font-mono);
|
|
364
|
+
color: var(--_qm-ink);
|
|
365
|
+
}
|
|
351
366
|
.qm-date-today {
|
|
352
367
|
margin-inline-start: auto;
|
|
353
368
|
margin-inline-end: calc(-1 * var(--_qm-space-2));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Inline diagnostic display (
|
|
2
|
+
Inline diagnostic display (INVARIANTS §Diagnostics). Errors only, non-gating:
|
|
3
3
|
purely additive, never disables the field it sits under. Shared by `Field.svelte`
|
|
4
4
|
(a scalar/prose field) and `Card.svelte` (the body leaf, which has no
|
|
5
5
|
`Field.svelte` wrapper), so a card's body diagnostics render the same way a
|
|
@@ -21,13 +21,45 @@
|
|
|
21
21
|
diagnostics: Diagnostic[] | undefined;
|
|
22
22
|
}
|
|
23
23
|
let { diagnostics }: Props = $props();
|
|
24
|
+
|
|
25
|
+
const CONTROLS =
|
|
26
|
+
'[contenteditable="true"], input, button.qm-select, [role="switch"], [role="checkbox"], [role="spinbutton"]';
|
|
27
|
+
|
|
28
|
+
const listId = $props.id();
|
|
29
|
+
|
|
30
|
+
/** Under a field's or a property's own control, the list marks that control
|
|
31
|
+
* `aria-invalid` for as long as it stands, so the state reaches assistive tech with
|
|
32
|
+
* the ring the stack draws (controls.css), and names itself as the control's error
|
|
33
|
+
* message, read after the description the control already carries. */
|
|
34
|
+
function markInvalid(node: HTMLElement) {
|
|
35
|
+
const stack = node.parentElement;
|
|
36
|
+
if (!stack?.matches('.qm-field-stack, .qm-prop-stack')) return;
|
|
37
|
+
const marked = [...stack.querySelectorAll<HTMLElement>(CONTROLS)];
|
|
38
|
+
for (const el of marked) {
|
|
39
|
+
el.setAttribute('aria-invalid', 'true');
|
|
40
|
+
el.setAttribute('aria-errormessage', node.id);
|
|
41
|
+
const by = el.getAttribute('aria-describedby')?.split(/\s+/).filter(Boolean) ?? [];
|
|
42
|
+
if (!by.includes(node.id)) el.setAttribute('aria-describedby', [...by, node.id].join(' '));
|
|
43
|
+
}
|
|
44
|
+
return () => {
|
|
45
|
+
for (const el of marked) {
|
|
46
|
+
el.removeAttribute('aria-invalid');
|
|
47
|
+
el.removeAttribute('aria-errormessage');
|
|
48
|
+
const by = (el.getAttribute('aria-describedby') ?? '')
|
|
49
|
+
.split(/\s+/)
|
|
50
|
+
.filter((id) => id && id !== node.id);
|
|
51
|
+
if (by.length) el.setAttribute('aria-describedby', by.join(' '));
|
|
52
|
+
else el.removeAttribute('aria-describedby');
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
24
56
|
</script>
|
|
25
57
|
|
|
26
58
|
{#if diagnostics && diagnostics.length}
|
|
27
59
|
<!-- role=status: commit errors appear mid-typing; announce without stealing focus. -->
|
|
28
|
-
<div class="qm-diag-list" role="status">
|
|
60
|
+
<div class="qm-diag-list" id={listId} role="status" {@attach markInvalid}>
|
|
29
61
|
{#each diagnostics as d, i (i)}
|
|
30
|
-
<span class="qm-diag-line">{diagnosticText(d, t.formatDiagnostic)}</span>
|
|
62
|
+
<span class="qm-diag-line">{diagnosticText(d, t.formatDiagnostic, t.strings)}</span>
|
|
31
63
|
{/each}
|
|
32
64
|
</div>
|
|
33
65
|
{/if}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
A `type: enum` field → a styled listbox over its `values`, on bits-ui.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
intent, expressible. The sentinel stays in the list once a value is authored, as
|
|
10
|
-
the "clear back to default" (unset) affordance.
|
|
2
|
+
A `type: enum` field → a styled listbox over its `values`, on bits-ui. The list is
|
|
3
|
+
the members, one row each, the current one checked and the `default:`'s tagged.
|
|
4
|
+
Unset, the trigger ghosts the default (muted, shown-never-written) and the default's
|
|
5
|
+
row carries the check, since that is what prints; picking it writes it, so "commit
|
|
6
|
+
the default" stays expressible as genuine intent. Once a value is authored a reset
|
|
7
|
+
row stands under a divider, the unset sentinel: it commits nothing, clearing back to
|
|
8
|
+
the default (or to nothing, where none prints).
|
|
11
9
|
|
|
12
10
|
Styled rather than a native `<select>`: the dropdown list is UA-owned and reaches
|
|
13
11
|
no dial. Listbox semantics and typeahead come with the primitive.
|
|
@@ -80,8 +78,10 @@
|
|
|
80
78
|
* `none`: it draws at the default rung (theme.css). */
|
|
81
79
|
const ghostsMember = $derived(!optional && !!fallback);
|
|
82
80
|
const ghostText = $derived(optional ? t.strings.optionalGhost : dash(fallback));
|
|
83
|
-
/** The
|
|
84
|
-
const
|
|
81
|
+
/** The reset row says where it goes: back to the default, or to nothing. */
|
|
82
|
+
const reset = $derived(ghostsMember ? t.strings.enumReset : t.strings.enumClear);
|
|
83
|
+
/** The member the list checks: the pick, or the default that prints while unset. */
|
|
84
|
+
const checked = $derived(unset ? (ghostsMember ? fallback : undefined) : local);
|
|
85
85
|
/** What the closed trigger shows: the pick, or the ghosted default while unset. */
|
|
86
86
|
const shown = $derived(unset ? ghostText : dash(local));
|
|
87
87
|
|
|
@@ -130,29 +130,11 @@
|
|
|
130
130
|
plain string and never picks up the scoping hash. -->
|
|
131
131
|
<div class="qm-menu-surface qm-select-content" data-qm-root>
|
|
132
132
|
<Select.Viewport>
|
|
133
|
-
<!-- The sentinel renders the `default:`'s own text, so a defaulted enum
|
|
134
|
-
lists that word twice: this row, and the member below it. The tag has
|
|
135
|
-
to be a word rather than a tone — the ghost is already `ink-label`,
|
|
136
|
-
and while the field is unset this is the selected row, so the weight
|
|
137
|
-
step pulls the other way. It rides the accessible name for the same
|
|
138
|
-
reason. -->
|
|
139
|
-
<!-- An optional cell's row is untagged: it ghosts no default, and `None`
|
|
140
|
-
names no member to tell it from. -->
|
|
141
|
-
<Select.Item
|
|
142
|
-
class="qm-menu-item qm-select-item qm-select-unset"
|
|
143
|
-
value={UNSET}
|
|
144
|
-
label={optional ? ghostText : `${ghostText} ${tag}`}
|
|
145
|
-
>
|
|
146
|
-
<span class="qm-select-ghost">{ghostText}</span>
|
|
147
|
-
{#if !optional}
|
|
148
|
-
<span class="qm-select-tag">{tag}</span>
|
|
149
|
-
{/if}
|
|
150
|
-
</Select.Item>
|
|
151
133
|
<!-- A refused option still draws under `'disable'`, and under either
|
|
152
134
|
policy when it is the one selected: a listbox whose selected value
|
|
153
135
|
has no row shows nothing for what the document says, and offers none
|
|
154
136
|
for the primitive to mark, type-ahead to, or key onto
|
|
155
|
-
(
|
|
137
|
+
(INVARIANTS §Enums). Off `local`, not `value`: the
|
|
156
138
|
row that exists is the row the control has selected, through the
|
|
157
139
|
window where an own pick has not reconciled back. -->
|
|
158
140
|
{#each values as v (v)}
|
|
@@ -163,11 +145,31 @@
|
|
|
163
145
|
value={v}
|
|
164
146
|
label={dash(v)}
|
|
165
147
|
disabled={!allowed}
|
|
148
|
+
data-checked={v === checked ? '' : undefined}
|
|
166
149
|
>
|
|
167
|
-
|
|
150
|
+
<span class="qm-select-check" aria-hidden="true">
|
|
151
|
+
{#if v === checked}<Icon name="check" />{/if}
|
|
152
|
+
</span>
|
|
153
|
+
<span class="qm-select-label">{dash(v)}</span>
|
|
154
|
+
{#if ghostsMember && v === fallback}
|
|
155
|
+
<span class="qm-select-tag">{t.strings.enumUnsetTag}</span>
|
|
156
|
+
{/if}
|
|
168
157
|
</Select.Item>
|
|
169
158
|
{/if}
|
|
170
159
|
{/each}
|
|
160
|
+
<!-- The reset is the sentinel, offered once there is something to reset:
|
|
161
|
+
unset, the list's check already stands where a reset would land. -->
|
|
162
|
+
{#if !unset}
|
|
163
|
+
<div class="qm-select-divider" role="separator"></div>
|
|
164
|
+
<Select.Item
|
|
165
|
+
class="qm-menu-item qm-select-item qm-select-unset"
|
|
166
|
+
value={UNSET}
|
|
167
|
+
label={reset}
|
|
168
|
+
>
|
|
169
|
+
<span class="qm-select-check" aria-hidden="true"></span>
|
|
170
|
+
<span class="qm-select-ghost">{reset}</span>
|
|
171
|
+
</Select.Item>
|
|
172
|
+
{/if}
|
|
171
173
|
</Select.Viewport>
|
|
172
174
|
</div>
|
|
173
175
|
</Select.Content>
|
|
@@ -229,8 +231,30 @@
|
|
|
229
231
|
max-height: 16rem;
|
|
230
232
|
overflow-y: auto;
|
|
231
233
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
+
/* A row is a check track, the member, and the default's tag at the end. */
|
|
235
|
+
.qm-select-content :global(.qm-select-item) {
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
gap: var(--_qm-space);
|
|
239
|
+
}
|
|
240
|
+
.qm-select-check {
|
|
241
|
+
flex-shrink: 0;
|
|
242
|
+
display: inline-flex;
|
|
243
|
+
width: var(--_qm-glyph-control);
|
|
244
|
+
height: var(--_qm-glyph-control);
|
|
245
|
+
}
|
|
246
|
+
.qm-select-check :global(svg) {
|
|
247
|
+
width: 100%;
|
|
248
|
+
height: 100%;
|
|
249
|
+
}
|
|
250
|
+
.qm-select-label {
|
|
251
|
+
flex: 1;
|
|
252
|
+
min-width: 0;
|
|
253
|
+
}
|
|
254
|
+
.qm-select-divider {
|
|
255
|
+
height: var(--_qm-border-width);
|
|
256
|
+
margin: var(--_qm-space) var(--_qm-space-2);
|
|
257
|
+
background: var(--_qm-border);
|
|
234
258
|
}
|
|
235
259
|
/* Consumer policy, for a refused option the list still draws: offered, unpickable. */
|
|
236
260
|
.qm-select-content :global(.qm-select-item[data-disabled]) {
|
|
@@ -240,18 +264,8 @@
|
|
|
240
264
|
.qm-select-ghost {
|
|
241
265
|
color: var(--_qm-ink-label);
|
|
242
266
|
}
|
|
243
|
-
/*
|
|
244
|
-
|
|
245
|
-
split; a member's row is one string and has nothing to distribute. */
|
|
246
|
-
.qm-select-content :global(.qm-select-unset) {
|
|
247
|
-
display: flex;
|
|
248
|
-
align-items: baseline;
|
|
249
|
-
justify-content: space-between;
|
|
250
|
-
gap: var(--_qm-space-2);
|
|
251
|
-
}
|
|
252
|
-
/* A step down the size ramp, which is what says this is chrome and the word beside
|
|
253
|
-
it is the value. The ink is the ghost's own: a second tone here would rank the
|
|
254
|
-
tag against the thing it annotates, and there is no rung under `label` to take
|
|
267
|
+
/* A step down the size ramp, which is what says this is chrome and the member beside
|
|
268
|
+
it is the value. The ink is the label rung, there being none under it to take
|
|
255
269
|
(theme.css, "nothing under the last"). */
|
|
256
270
|
.qm-select-tag {
|
|
257
271
|
flex-shrink: 0;
|
package/dist/visual/Field.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Type dispatch (
|
|
2
|
+
Type dispatch (INVARIANTS §"Structure mirrors the schema"). Given one projected
|
|
3
3
|
{@link FieldModel} and its live value, render the label + the control the type
|
|
4
4
|
maps to. Array and matrix controls own their label (paired with the add affordance in
|
|
5
5
|
{@link ArrayField}, with the held count in {@link MatrixField}); other types render
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
`diagnostics` is the routed `Diagnostic[]` for this field (VisualEditor's
|
|
14
14
|
`diagByKey`, merging `quill.validate`, local commit errors, and the external
|
|
15
|
-
`diagnostics` prop (
|
|
15
|
+
`diagnostics` prop (INVARIANTS §Diagnostics)) rendered via the shared
|
|
16
16
|
`DiagnosticList`, non-gating; each set also re-evaluates a prose leaf's hold
|
|
17
17
|
(`ProseField`).
|
|
18
18
|
-->
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
} from '@quillmark/wasm';
|
|
29
29
|
import type { EditorErrorHandler } from '../core/errors.js';
|
|
30
30
|
import { seatValueLeaves, stepsTo, type LandingBox, type LeafRegistry } from './leaves.js';
|
|
31
|
-
import type { FieldModel, FieldSpan } from './structure.js';
|
|
31
|
+
import type { FieldModel, FieldSpan, RunTail } from './structure.js';
|
|
32
32
|
import {
|
|
33
33
|
VARIANT_DISCRIMINANT,
|
|
34
34
|
arrayLayout,
|
|
@@ -62,6 +62,8 @@
|
|
|
62
62
|
field: FieldModel;
|
|
63
63
|
/** This field's width in the section grid, from `placeFields`. */
|
|
64
64
|
span: FieldSpan;
|
|
65
|
+
/** Where a cell takes the row its run's length would leave it alone in. */
|
|
66
|
+
tail?: RunTail;
|
|
65
67
|
value: unknown;
|
|
66
68
|
/** This field's resolved provenance row (FIELD_PROVENANCE): the ghost's
|
|
67
69
|
* source. Feeds the placeholder / fallback only, never `value`. */
|
|
@@ -99,6 +101,7 @@
|
|
|
99
101
|
let {
|
|
100
102
|
field,
|
|
101
103
|
span,
|
|
104
|
+
tail,
|
|
102
105
|
value,
|
|
103
106
|
provenance,
|
|
104
107
|
doc,
|
|
@@ -126,7 +129,7 @@
|
|
|
126
129
|
// object-valued default has none. An array draws its declared literal instead,
|
|
127
130
|
// which is what a take writes (`ArrayField`).
|
|
128
131
|
// A default that prints stands in the control as the value it is, at the default
|
|
129
|
-
// rung, and the first edit takes it (
|
|
132
|
+
// rung, and the first edit takes it (INVARIANTS §"The commitment ladder"). Where
|
|
130
133
|
// nothing prints, a control draws words: the `none` an optional cell prints.
|
|
131
134
|
const ghost = $derived(ghostDefault(provenance));
|
|
132
135
|
const defaultStr = $derived(
|
|
@@ -285,7 +288,7 @@
|
|
|
285
288
|
);
|
|
286
289
|
</script>
|
|
287
290
|
|
|
288
|
-
<div class={['qm-field', { cell: span === 'cell' }]}>
|
|
291
|
+
<div class={['qm-field', { cell: span === 'cell' }]} data-tail={tail}>
|
|
289
292
|
{#if !ownsLabel && !headed}
|
|
290
293
|
<FieldLabel
|
|
291
294
|
label={field.label}
|
|
@@ -330,7 +333,7 @@
|
|
|
330
333
|
<EnumField
|
|
331
334
|
value={value as string | undefined}
|
|
332
335
|
values={field.schema.values ?? []}
|
|
333
|
-
fallback={ghost as string | undefined}
|
|
336
|
+
fallback={(ghost as string | undefined) ?? declared}
|
|
334
337
|
blankTitle={field.schema.ui?.blank_title}
|
|
335
338
|
{optional}
|
|
336
339
|
id={domIds.control}
|
|
@@ -486,6 +489,13 @@
|
|
|
486
489
|
row-gap: var(--_qm-space);
|
|
487
490
|
align-items: start;
|
|
488
491
|
}
|
|
492
|
+
/* A run's last cell where its capacity would leave it alone in the row (`RunTail`). */
|
|
493
|
+
.qm-field.cell[data-tail='odd'] {
|
|
494
|
+
grid-column: var(--tail-odd);
|
|
495
|
+
}
|
|
496
|
+
.qm-field.cell[data-tail='lone'] {
|
|
497
|
+
grid-column: var(--tail-lone);
|
|
498
|
+
}
|
|
489
499
|
/* The stack the control's track holds: the control, and the diagnostics when
|
|
490
500
|
there are any. Its gap is the field's own, so a diagnostic sits the same rung
|
|
491
501
|
under its control that the control sits under its label. */
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Document, Quill, Addr, Diagnostic, PathStep, ResolvedField } from '@quillmark/wasm';
|
|
2
2
|
import type { EditorErrorHandler } from '../core/errors.js';
|
|
3
3
|
import { type LeafRegistry } from './leaves.js';
|
|
4
|
-
import type { FieldModel, FieldSpan } from './structure.js';
|
|
4
|
+
import type { FieldModel, FieldSpan, RunTail } from './structure.js';
|
|
5
5
|
import type { FieldDomIds } from './domid.js';
|
|
6
6
|
interface Props {
|
|
7
7
|
field: FieldModel;
|
|
8
8
|
/** This field's width in the section grid, from `placeFields`. */
|
|
9
9
|
span: FieldSpan;
|
|
10
|
+
/** Where a cell takes the row its run's length would leave it alone in. */
|
|
11
|
+
tail?: RunTail;
|
|
10
12
|
value: unknown;
|
|
11
13
|
/** This field's resolved provenance row (FIELD_PROVENANCE): the ghost's
|
|
12
14
|
* source. Feeds the placeholder / fallback only, never `value`. */
|