@quillmark/svelte 0.29.3 → 0.31.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.
Files changed (63) hide show
  1. package/README.md +3 -3
  2. package/dist/core/address.d.ts +3 -3
  3. package/dist/core/address.js +1 -1
  4. package/dist/core/codec/decode.d.ts +4 -5
  5. package/dist/core/codec/decode.js +151 -208
  6. package/dist/core/codec/encode.d.ts +13 -35
  7. package/dist/core/codec/encode.js +127 -408
  8. package/dist/core/codec/field.d.ts +11 -10
  9. package/dist/core/codec/field.js +190 -92
  10. package/dist/core/codec/index.d.ts +2 -2
  11. package/dist/core/codec/index.js +4 -4
  12. package/dist/core/codec/islands.d.ts +13 -9
  13. package/dist/core/codec/islands.js +54 -49
  14. package/dist/core/codec/marks.d.ts +12 -18
  15. package/dist/core/codec/marks.js +16 -26
  16. package/dist/core/codec/positions.d.ts +25 -7
  17. package/dist/core/codec/positions.js +43 -50
  18. package/dist/core/codec/prose.css +0 -8
  19. package/dist/core/codec/schema.d.ts +3 -3
  20. package/dist/core/codec/schema.js +29 -11
  21. package/dist/core/codec/slash.d.ts +4 -2
  22. package/dist/core/codec/slash.js +13 -3
  23. package/dist/core/codec/table-copy.d.ts +3 -3
  24. package/dist/core/codec/table-copy.js +6 -4
  25. package/dist/core/codec/table-paste.js +13 -9
  26. package/dist/core/codec/table-view.js +19 -12
  27. package/dist/core/codec/table.d.ts +77 -43
  28. package/dist/core/codec/table.js +157 -48
  29. package/dist/core/index.d.ts +1 -0
  30. package/dist/core/theme.css +14 -6
  31. package/dist/visual/ArrayField.svelte +168 -83
  32. package/dist/visual/BooleanField.svelte +2 -2
  33. package/dist/visual/Card.svelte +65 -44
  34. package/dist/visual/DateField.svelte +16 -1
  35. package/dist/visual/DiagnosticList.svelte +34 -2
  36. package/dist/visual/EnumField.svelte +58 -44
  37. package/dist/visual/Field.svelte +13 -3
  38. package/dist/visual/Field.svelte.d.ts +3 -1
  39. package/dist/visual/FieldHint.svelte +10 -3
  40. package/dist/visual/FormatPopover.svelte +1 -1
  41. package/dist/visual/MatrixAdd.svelte +3 -18
  42. package/dist/visual/MatrixField.svelte +20 -12
  43. package/dist/visual/ObjectField.svelte +164 -145
  44. package/dist/visual/ProseField.svelte +6 -1
  45. package/dist/visual/ProseValue.svelte +8 -8
  46. package/dist/visual/SlashMenu.svelte +24 -12
  47. package/dist/visual/SlashMenu.svelte.d.ts +2 -0
  48. package/dist/visual/VisualEditor.svelte +1 -1
  49. package/dist/visual/VisualEditor.svelte.d.ts +1 -1
  50. package/dist/visual/VisualEditorInner.svelte +159 -18
  51. package/dist/visual/VisualEditorInner.svelte.d.ts +1 -1
  52. package/dist/visual/controls.css +42 -4
  53. package/dist/visual/leaves.d.ts +1 -1
  54. package/dist/visual/leaves.js +1 -1
  55. package/dist/visual/strings.d.ts +27 -10
  56. package/dist/visual/strings.js +40 -6
  57. package/dist/visual/structure.d.ts +17 -9
  58. package/dist/visual/structure.js +20 -26
  59. package/dist/visual/undo.svelte.d.ts +36 -0
  60. package/dist/visual/undo.svelte.js +119 -0
  61. package/package.json +2 -2
  62. package/dist/visual/hold.d.ts +0 -17
  63. package/dist/visual/hold.js +0 -39
@@ -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 { holdInView } from './hold.js';
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
- // Seeded once from the card's shape. Card is keyed by stable id, so this survives the
138
- // VisualEditor re-derive that reassigns `card` and resets only on a remount. Not
139
- // reconciled to later section changes: a retype is the one reshape, and the open
140
- // group stays where it still exists.
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
- let expanded = $state<string | null>(initialExpandedGroup(card.sections));
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 `expanded` is about to make. False for a reveal
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
- * Move to `next` (`null` = all closed). A closing panel goes `inert` with whatever it
151
- * held still focused, and `inert` does not say where focus should go — the browser
152
- * drops it on the body — so the close hands focus to the header, which is what
153
- * reopens the section. Every write to `expanded` goes through here: a group also
154
- * closes when another opens.
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
- holdInView(headers[group], () => setExpanded(expanded === group ? null : group));
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
- * `expanded` is assigned.
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 the accordion under the user.
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
- setExpanded(section.group);
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 accordion uses: a scroll's behaviour is an argument, not a transition a
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
- <!-- One open at a time. Rendered only when a card has groups, so an empty
270
- accordion does not stand a gap under the ungrouped fields. -->
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 = expanded === group}
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}
@@ -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: a card title and a section header both name a block
508
- of fields, so they read as one register and what ranks them is position rather than
509
- a size step. */
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 (ARCHITECTURE §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-body);
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. A
529
- typed title is a value, at the ink, and the automatic one a placeholder, at label
530
- ink, as in every field. */
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-label);
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
- /* One rung between the payload's two kinds of section, and none inside the accordion:
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
@@ -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. The
588
- accordion spends the same rung from its header and its panel, where it also caps the
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
@@ -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 accordion stops looking like structure. Size, weight and leading sit after
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 accordion animates for it. Both panels of the move are inside the group box,
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;
@@ -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: an empty field is the honest render.
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));
@@ -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. When
3
- nothing is authored the list shows a distinct unset
4
- sentinel that ghosts the `default:` (muted, shown-never-written), distinguishable
5
- from an authored pick and re-selectable; so re-picking the default fires a
6
- change. The sentinel commits nothing; any real pick: including the
7
- value that equals the default: commits via the parent's typed `writer.set`.
8
- Explicitly picking the default is the one place "commit the default" is genuine
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 sentinel's tag says what picking it does: return to the default, or unset. */
84
- const tag = $derived(ghostsMember ? t.strings.enumUnsetTag : t.strings.enumUnsetTagNone);
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,24 +130,6 @@
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
@@ -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
- {dash(v)}
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
- .qm-select-content :global(.qm-select-item[data-selected]) {
233
- font-weight: var(--_qm-weight-strong);
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
- /* The sentinel's row: the ghost at one end, the tag at the other, so the pair reads
244
- as a value and a note about it rather than as two words. Only this row takes the
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;
@@ -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,
@@ -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`. */
@@ -252,8 +252,8 @@
252
252
 
253
253
  It takes no fill either: the surface itself opens on hover.
254
254
 
255
- At rest it recedes to the idle rung, a card describing every field otherwise
256
- standing a mark beside each label before anything is touched. It lifts with the
255
+ At rest it is absent, a card describing every field otherwise standing a mark
256
+ beside each label before anything is touched. It arrives with the
257
257
  scope that owns its row (the field, the property, the array or matrix, the table
258
258
  its column heads, the section a lone field is named by), each reached by child
259
259
  steps so a nested field's marker stays at rest under its container's hover, and
@@ -266,7 +266,7 @@
266
266
  cursor: help;
267
267
  padding: 0;
268
268
  background: none;
269
- opacity: var(--_qm-opacity-idle);
269
+ opacity: 0;
270
270
  transition: opacity var(--_qm-duration-fast) var(--_qm-ease-reverse);
271
271
  }
272
272
  :global(:is(.qm-field, .qm-object-prop):is(:hover, :focus-within) > .qm-field-label-row)
@@ -281,6 +281,13 @@
281
281
  .qm-field-hint[aria-expanded='true'] {
282
282
  opacity: 1;
283
283
  }
284
+ /* Without a hover there is no lift to wait for, and a tap is the glyph's only door, so
285
+ it rests drawn at the rung a live glyph control rests at. */
286
+ @media (hover: none) {
287
+ .qm-field-hint {
288
+ opacity: var(--_qm-opacity-rest);
289
+ }
290
+ }
284
291
  /* The lift, the translucency, the blur and the scale-in come from
285
292
  `.qm-popover-surface` (controls.css). This surface's own is a measure: guidance
286
293
  is prose, and prose past ~40 characters a line stops being scannable; plus the
@@ -8,7 +8,7 @@
8
8
  raises it over that leaf's selection rect; each button dispatches a PM `toggleMark`
9
9
  command straight at the leaf's `EditorView`, whose own `dispatchTransaction` commits
10
10
  the result as it commits a keystroke: a field's lowers it to `markOps` through
11
- `applyChange` (field.ts), a by-value leaf's hands the re-encoded value to its parent
11
+ `apply` (field.ts), a by-value leaf's hands the re-encoded value to its parent
12
12
  (`ProseValue`). This component never touches the content. The keymap mirror
13
13
  (Mod-b/i/u, Mod-Shift-x, Mod-e) lives in the codec's keymap (field.ts); this is
14
14
  the pointer affordance for all six marks. Mod-K is this surface's own key, the
@@ -75,18 +75,9 @@
75
75
  height: var(--_qm-glyph-control);
76
76
  color: var(--_qm-ink-label);
77
77
  }
78
- /* At rest the box is the add chip it stands in for: no well, its words at the label
79
- ink, and the line at the chip's idle rung. The line comes up under the pointer with
80
- the well, and both stay while the box holds the focus or typed words. */
81
- .qm-matrix-add-field {
82
- opacity: var(--_qm-opacity-idle);
83
- transition: opacity var(--_qm-duration-fast) var(--_qm-ease-reverse);
84
- }
85
- .qm-matrix-add-field:hover,
86
- .qm-matrix-add-field:focus-within,
87
- .qm-matrix-add-field:has(.qm-input:not(:placeholder-shown)) {
88
- opacity: 1;
89
- }
78
+ /* At rest the box is the add chip it stands in for: no well, and its words at the
79
+ label ink in full, as the add chip's are: words take the text floor, not the rest rung
80
+ a glyph control rests at. */
90
81
  .qm-matrix-add-field .qm-input {
91
82
  flex: 1;
92
83
  min-width: 0;
@@ -100,10 +91,4 @@
100
91
  .qm-matrix-add-field:hover .qm-input:placeholder-shown:not(:focus) {
101
92
  background: var(--_qm-surface-hover);
102
93
  }
103
- /* No hover to come up on: the line stands at the muted rung, as the chip does. */
104
- @media (hover: none) {
105
- .qm-matrix-add-field {
106
- opacity: var(--_qm-opacity-muted);
107
- }
108
- }
109
94
  </style>