@quillmark/svelte 0.35.1 → 0.36.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 (60) hide show
  1. package/README.md +21 -13
  2. package/dist/core/address.d.ts +5 -0
  3. package/dist/core/address.js +14 -0
  4. package/dist/core/codec/field.d.ts +30 -7
  5. package/dist/core/codec/field.js +67 -4
  6. package/dist/core/codec/index.d.ts +6 -3
  7. package/dist/core/codec/index.js +2 -3
  8. package/dist/core/codec/prose.css +11 -77
  9. package/dist/core/codec/review.d.ts +27 -21
  10. package/dist/core/codec/review.js +87 -148
  11. package/dist/core/codec/shortcuts.d.ts +3 -3
  12. package/dist/core/codec/shortcuts.js +7 -7
  13. package/dist/core/codec/value-diff.d.ts +21 -0
  14. package/dist/core/codec/value-diff.js +83 -0
  15. package/dist/core/codec/value-plan.d.ts +29 -0
  16. package/dist/core/codec/value-plan.js +157 -0
  17. package/dist/core/theme.css +7 -2
  18. package/dist/visual/ArrayField.svelte +191 -17
  19. package/dist/visual/Card.svelte +12 -1
  20. package/dist/visual/Card.svelte.d.ts +3 -0
  21. package/dist/visual/EnumField.svelte +14 -4
  22. package/dist/visual/EnumField.svelte.d.ts +3 -0
  23. package/dist/visual/Field.svelte +56 -47
  24. package/dist/visual/FieldHint.svelte +1 -0
  25. package/dist/visual/FormatPopover.svelte +1 -0
  26. package/dist/visual/MatrixField.svelte +43 -5
  27. package/dist/visual/MatrixField.svelte.d.ts +5 -0
  28. package/dist/visual/NumberField.svelte +112 -3
  29. package/dist/visual/NumberField.svelte.d.ts +5 -0
  30. package/dist/visual/ObjectField.svelte +54 -16
  31. package/dist/visual/ProseField.svelte +16 -3
  32. package/dist/visual/ProseField.svelte.d.ts +3 -0
  33. package/dist/visual/ProseValue.svelte +38 -2
  34. package/dist/visual/ProseValue.svelte.d.ts +3 -0
  35. package/dist/visual/ReviewCard.svelte +347 -0
  36. package/dist/visual/ReviewCard.svelte.d.ts +19 -0
  37. package/dist/visual/ReviewProposal.svelte +104 -138
  38. package/dist/visual/ReviewProposal.svelte.d.ts +3 -6
  39. package/dist/visual/ReviewRows.svelte +6 -25
  40. package/dist/visual/ReviewRows.svelte.d.ts +1 -3
  41. package/dist/visual/SlashMenu.svelte +1 -0
  42. package/dist/visual/VariantField.svelte +44 -4
  43. package/dist/visual/VariantField.svelte.d.ts +5 -0
  44. package/dist/visual/VisualEditor.svelte +16 -7
  45. package/dist/visual/VisualEditor.svelte.d.ts +3 -0
  46. package/dist/visual/VisualEditorInner.svelte +840 -115
  47. package/dist/visual/VisualEditorInner.svelte.d.ts +3 -0
  48. package/dist/visual/index.d.ts +2 -2
  49. package/dist/visual/proposals.d.ts +13 -22
  50. package/dist/visual/proposals.js +69 -32
  51. package/dist/visual/props.d.ts +18 -18
  52. package/dist/visual/review.d.ts +68 -3
  53. package/dist/visual/review.js +36 -1
  54. package/dist/visual/review.svelte.d.ts +55 -15
  55. package/dist/visual/review.svelte.js +156 -42
  56. package/dist/visual/strings.d.ts +23 -6
  57. package/dist/visual/strings.js +10 -5
  58. package/dist/visual/undo.svelte.d.ts +3 -1
  59. package/dist/visual/undo.svelte.js +7 -3
  60. package/package.json +1 -1
@@ -0,0 +1,157 @@
1
+ import { wordDiff } from './review-diff.js';
2
+ /** Line `k`'s block where a value of words names none of its own. */
3
+ const para = (_, k) => ({ id: `b${k}`, kind: 'para' });
4
+ /** A field value of words as a `Content`: a string by its lines, a rich or plain text value as it
5
+ * is, nothing as the empty line. `undefined` for a value that is not words. */
6
+ export function asContent(value) {
7
+ if (value == null)
8
+ return { text: '', blocks: [para(null, 0)] };
9
+ if (typeof value === 'string')
10
+ return { text: value, blocks: value.split('\n').map(para) };
11
+ if (typeof value !== 'object' || typeof value.text !== 'string')
12
+ return undefined;
13
+ const v = value;
14
+ return Array.isArray(v.blocks) ? v : { ...v, blocks: v.text.split('\n').map(para) };
15
+ }
16
+ const markKey = (m) => JSON.stringify([m.type, 'attrs' in m ? (m.attrs ?? null) : null]);
17
+ /** The marks over each offset of `c`, as one key per offset. */
18
+ function marksAt(c) {
19
+ const out = new Array(c.text.length);
20
+ for (let i = 0; i < out.length; i++)
21
+ out[i] = [];
22
+ for (const m of c.marks ?? [])
23
+ for (let i = m.start; i < m.end && i < out.length; i++)
24
+ out[i].push(markKey(m));
25
+ return out.map((keys) => keys.sort().join('|'));
26
+ }
27
+ /**
28
+ * The changes that take `a` to `b`, in order and apart: the words that differ, then, in the words
29
+ * both hold, each run whose formatting differs, which gives way to itself as `b` formats it.
30
+ */
31
+ export function valueChanges(a, b) {
32
+ const words = [];
33
+ let shift = 0;
34
+ for (const h of wordDiff(a.text, b.text)) {
35
+ const from = h.at + shift;
36
+ words.push({ at: h.at, end: h.end, from, to: from + h.insert.length });
37
+ shift += h.insert.length - (h.end - h.at);
38
+ }
39
+ if (!(a.marks?.length || b.marks?.length))
40
+ return words;
41
+ const ma = marksAt(a);
42
+ const mb = marksAt(b);
43
+ const out = [];
44
+ let i = 0;
45
+ let j = 0;
46
+ const kept = (end) => {
47
+ let run;
48
+ for (; i < end; i++, j++) {
49
+ if (ma[i] === mb[j]) {
50
+ if (run)
51
+ out.push(run);
52
+ run = undefined;
53
+ continue;
54
+ }
55
+ if (run) {
56
+ run.end = i + 1;
57
+ run.to = j + 1;
58
+ }
59
+ else
60
+ run = { at: i, end: i + 1, from: j, to: j + 1 };
61
+ }
62
+ if (run)
63
+ out.push(run);
64
+ };
65
+ for (const w of words) {
66
+ kept(w.at);
67
+ out.push(w);
68
+ i = w.end;
69
+ j = w.to;
70
+ }
71
+ kept(a.text.length);
72
+ return out;
73
+ }
74
+ /** Whether two changes over one value touch the same words: they overlap, or one inserts inside
75
+ * the other, or both insert at one place. */
76
+ function meet(p, r) {
77
+ if (p.at < r.end && r.at < p.end)
78
+ return true;
79
+ if (p.at === p.end && r.at === r.end)
80
+ return p.at === r.at;
81
+ if (p.at === p.end)
82
+ return p.at > r.at && p.at < r.end;
83
+ if (r.at === r.end)
84
+ return r.at > p.at && r.at < p.end;
85
+ return false;
86
+ }
87
+ /** The marks of `[from, to)` of `c`, from `at`. */
88
+ function marksIn(c, from, to, at) {
89
+ return (c.marks ?? []).flatMap((m) => {
90
+ const start = Math.max(m.start, from);
91
+ const end = Math.min(m.end, to);
92
+ return end > start ? [{ ...m, start: start - from + at, end: end - from + at }] : [];
93
+ });
94
+ }
95
+ /** One mark for each run of touching marks of one kind. */
96
+ function joinMarks(marks) {
97
+ const sorted = [...marks].sort((x, y) => x.start - y.start || x.end - y.end);
98
+ const out = [];
99
+ for (const m of sorted) {
100
+ const prev = out.find((o) => markKey(o) === markKey(m) && o.end >= m.start);
101
+ if (prev)
102
+ prev.end = Math.max(prev.end, m.end);
103
+ else
104
+ out.push({ ...m });
105
+ }
106
+ return out.sort((x, y) => x.start - y.start || x.end - y.end);
107
+ }
108
+ /** `c` with `[at, end)` giving way to `[from, to)` of `src`, marks and all. */
109
+ function splice(c, at, end, src, from, to) {
110
+ const delta = to - from - (end - at);
111
+ const text = c.text.slice(0, at) + src.text.slice(from, to) + c.text.slice(end);
112
+ const marks = joinMarks([
113
+ ...marksIn(c, 0, at, 0),
114
+ ...marksIn(c, end, c.text.length, end + delta),
115
+ ...marksIn(src, from, to, at)
116
+ ]);
117
+ const lines = text.split('\n').length;
118
+ const blocks = lines === c.blocks.length
119
+ ? c.blocks
120
+ : Array.from({ length: lines }, (_, k) => c.blocks[k] ?? para(null, k));
121
+ const out = { ...c, text, blocks };
122
+ if (marks.length)
123
+ out.marks = marks;
124
+ else
125
+ delete out.marks;
126
+ delete out.anchors;
127
+ return out;
128
+ }
129
+ /** Whether a value holds a block of its own kind, a container or an island, which a change to
130
+ * its words alone does not carry. */
131
+ const structured = (c) => !!c.islands?.length ||
132
+ !!c.containers?.length ||
133
+ c.blocks.some((b) => b.kind !== 'para' || b.path?.length);
134
+ /**
135
+ * What Accept writes over `live`, the value as it reads now: `after` where there is no `before`,
136
+ * or where the reader has changed nothing since; else each change from `before` to `after` carried
137
+ * onto `live`, the reader's own changes kept. Where a change of the reader's meets one of the
138
+ * proposal's, or the value holds more than lines of words, it is `after` whole and outdated, unless
139
+ * the value already reads as `after`.
140
+ */
141
+ export function planValue(before, live, after) {
142
+ if (!before)
143
+ return { merged: after, outdated: false };
144
+ const ours = valueChanges(before, live);
145
+ if (!ours.length || !valueChanges(live, after).length)
146
+ return { merged: after, outdated: false };
147
+ const theirs = valueChanges(before, after);
148
+ if ([before, live, after].some(structured) || theirs.some((p) => ours.some((r) => meet(p, r))))
149
+ return { merged: after, outdated: true };
150
+ const moved = (x) => ours.reduce((at, r) => (r.end <= x ? at + (r.to - r.from) - (r.end - r.at) : at), x);
151
+ let merged = live;
152
+ for (const p of [...theirs].reverse()) {
153
+ const at = moved(p.at);
154
+ merged = splice(merged, at, at + (p.end - p.at), after, p.from, p.to);
155
+ }
156
+ return { merged, outdated: false };
157
+ }
@@ -219,10 +219,15 @@
219
219
  the strength the accent's own tint is held under body text plus what a state resting
220
220
  on a well has to clear. `lit` is that tint under attention: the pointer over the
221
221
  item, the caret in it, a host revealing it. `line` is the stroke through the words a
222
- proposal would take, held back so it reads under the ink rather than as it. */
222
+ proposal would take, held back so it reads under the ink rather than as it, yet at 3:1 over
223
+ the card and a well at both poles, being the one mark a struck word or a tinted control's
224
+ edge has that is not colour alone: 75% of the light pole's hue, 60% of the dark's. */
223
225
  --_qm-review-tint: color-mix(in oklab, var(--_qm-review) 20%, transparent);
224
226
  --_qm-review-lit: color-mix(in oklab, var(--_qm-review) 34%, transparent);
225
- --_qm-review-line: color-mix(in oklab, var(--_qm-review) 60%, transparent);
227
+ --_qm-review-line: light-dark(
228
+ color-mix(in oklab, var(--_qm-review) 75%, transparent),
229
+ color-mix(in oklab, var(--_qm-review) 60%, transparent)
230
+ );
226
231
  /* The danger hue held: what a destructive control fills with where the family's
227
232
  neutral hover rung would read as one more button. Mixed at the accent tint's
228
233
  strength, so a held tint is a held tint whichever hue it carries. */
@@ -113,7 +113,17 @@
113
113
  textCap,
114
114
  type ArrayLayout
115
115
  } from './structure.js';
116
- import { splitReview, type DeepReview } from './review.js';
116
+ import {
117
+ numberProposal,
118
+ textProposal,
119
+ type TextProposal,
120
+ splitReview,
121
+ valueIn,
122
+ type DeepReview,
123
+ type FieldProposal
124
+ } from './review.js';
125
+ import { review as reviewState } from './review.svelte.js';
126
+ import { asContent } from '../core/codec/index.js';
117
127
  import ReviewRows from './ReviewRows.svelte';
118
128
  import { splitDeep, unrouted, type DeepDiagnostic } from './diagnostics.js';
119
129
  import { propertyDomIds } from './domid.js';
@@ -239,18 +249,79 @@
239
249
  const rowReview = (k: number): DeepReview[] =>
240
250
  k < arr.length ? (reviewed.below.get(k) ?? []) : [];
241
251
  const ownReview = (k: number): DeepReview[] => rowReview(k).filter((e) => !e.steps.length);
252
+ /** A row's own removal: the proposal that takes the member out, drawn on the whole row. */
253
+ const removal = (k: number): FieldProposal | undefined =>
254
+ ownReview(k).find((e) => e.item.after === undefined)?.item;
255
+ /** A row's items its controls mark, less its removal, which the row draws. */
256
+ const rowKept = (k: number): DeepReview[] => {
257
+ const gone = removal(k);
258
+ return gone ? rowReview(k).filter((e) => e.item !== gone) : rowReview(k);
259
+ };
242
260
  const innerReview = (k: number): DeepReview[] => rowReview(k).filter((e) => e.steps.length);
261
+ /** A scalar row's own proposal, which the row draws in place: a line of text as a word diff
262
+ * over the row, any other value as the value it would hold. A removal stays a mark. */
263
+ const rowOwn = (k: number): FieldProposal | undefined =>
264
+ scalar || control === 'prose'
265
+ ? ownReview(k).find((e) => e.item.after !== undefined)?.item
266
+ : undefined;
267
+ const rowText = (k: number): TextProposal | undefined =>
268
+ control === 'prose' ? textProposal(rowOwn(k)) : undefined;
269
+ const rowNumber = (k: number): { id: string; after: string } | undefined =>
270
+ control === 'number' ? numberProposal(rowOwn(k)) : undefined;
271
+ const rowWorded = (k: number): { id: string } | undefined => rowText(k) ?? rowNumber(k);
272
+ const rowShown = (k: number): unknown => {
273
+ const own = rowWorded(k) ? undefined : rowOwn(k);
274
+ return own ? own.after : arr[k];
275
+ };
276
+ /** A commit on a row that shows one value answers the proposal on it: the proposed value
277
+ * accepts it, any other dismisses it. */
278
+ const commitRow = (k: number, v: unknown): void => {
279
+ const own = rowWorded(k) ? undefined : rowOwn(k);
280
+ if (own && reviewing.answerWith(own.id, v)) return;
281
+ commitElement(k, v);
282
+ };
283
+ /** A row's marks: its proposals less the one its control draws as words. */
284
+ const rowMarks = (k: number): DeepReview[] => {
285
+ const text = rowWorded(k);
286
+ return text ? rowKept(k).filter((e) => e.item.id !== text.id) : rowKept(k);
287
+ };
288
+ /** What a row taken out carries: its item's id, the current one lit, and the pointer naming
289
+ * it, so the row is where the answer card stands. */
290
+ const removedRow = (k: number) => {
291
+ const gone = removal(k);
292
+ return gone
293
+ ? {
294
+ 'data-qm-review': gone.id,
295
+ 'data-qm-removed': '',
296
+ 'data-qm-removed-lit': reviewing.lit === gone.id ? '' : undefined,
297
+ onpointerenter: () => reviewing.point(gone.id, 'pointer'),
298
+ onpointerleave: () => reviewing.point(undefined, 'pointer')
299
+ }
300
+ : {};
301
+ };
243
302
  /** What has no row to draw under: a member past the last, and a place no row holds. A
244
303
  * table's rows are cells alone, so a member's own item is drawn here too, by its number. */
245
- const reviewFoot = $derived([
304
+ const footAll = $derived([
246
305
  ...reviewed.here,
247
306
  ...[...reviewed.below].flatMap(([step, list]) => {
248
307
  const held = typeof step === 'number' && step >= 0 && step < arr.length;
249
308
  return list
250
- .filter((e) => !held || (table && !e.steps.length))
309
+ .filter((e) => !held || (table && !e.steps.length && e.item.after !== undefined))
251
310
  .map((e) => ({ steps: [step, ...e.steps], item: e.item }));
252
311
  })
253
312
  ]);
313
+ /** Members past the last, drawn as preview rows where they would stand. */
314
+ const added = $derived(
315
+ footAll.filter(
316
+ (e) =>
317
+ e.steps.length === 1 &&
318
+ typeof e.steps[0] === 'number' &&
319
+ e.steps[0] >= arr.length &&
320
+ e.item.after !== undefined
321
+ )
322
+ );
323
+ const reviewFoot = $derived(footAll.filter((e) => !added.includes(e)));
324
+ const reviewing = reviewState();
254
325
 
255
326
  // Parallel stable ids, one per element, kept in lockstep with the data below.
256
327
  // Seeded eagerly so a non-empty array renders its rows on the first pass:
@@ -270,7 +341,7 @@
270
341
  (max == null || max > 0)
271
342
  );
272
343
  /** Whether the standing row is drawn: a gesture lands on it, which holds no element yet. */
273
- const onStanding = $derived(standing && ids.length === 0);
344
+ const onStanding = $derived(standing && ids.length === 0 && !added.length);
274
345
  /** The add chip's standing row after a list of numbers (see the header). */
275
346
  let adding = $state(false);
276
347
  const pending = $derived(adding && control === 'number' && ids.length > 0 && !atCap);
@@ -957,6 +1028,7 @@
957
1028
  data-qm-index={k}
958
1029
  bind:this={rowEls[id]}
959
1030
  onkeydown={(e) => onRowKey(e, k)}
1031
+ {...removedRow(k)}
960
1032
  >
961
1033
  <ObjectField
962
1034
  bare
@@ -974,6 +1046,7 @@
974
1046
  {@render removeButton(k, true)}
975
1047
  </div>
976
1048
  {/each}
1049
+ {#each added as { item }, n (item.id)}{@render addedRow(item, arr.length + n)}{/each}
977
1050
  </div>
978
1051
  </div>
979
1052
  {:else if control === 'object'}
@@ -996,6 +1069,7 @@
996
1069
  bind:this={rowEls[id]}
997
1070
  animate:reorder={arm.armed}
998
1071
  onkeydown={(e) => onRowKey(e, k)}
1072
+ {...removedRow(k)}
999
1073
  >
1000
1074
  <!-- The head is the row in collapsed form, and it is a box: the element IS
1001
1075
  a value, the way the enum trigger is, and the slab's grammar (the box's
@@ -1020,6 +1094,9 @@
1020
1094
  {#if !open.has(id) && preview(k)}
1021
1095
  <span class="qm-element-preview">{preview(k)}</span>
1022
1096
  {/if}
1097
+ {#if removal(k)}
1098
+ <span class="qm-review-tag">{t.strings.reviewRemoveCard}</span>
1099
+ {/if}
1023
1100
  </button>
1024
1101
  <div class="qm-row-actions">
1025
1102
  {@render removeButton(k)}
@@ -1037,19 +1114,20 @@
1037
1114
  diagnostics={routed.below.get(k)}
1038
1115
  review={innerReview(k)}
1039
1116
  />
1040
- <ReviewRows entries={ownReview(k)} value={arr[k]} member />
1117
+ <ReviewRows entries={ownReview(k).filter((e) => e.item !== removal(k))} member />
1041
1118
  {:else}
1042
1119
  <!-- A collapsed row draws no cell, so what its cells would have said is said
1043
1120
  under the head, where the row can be seen: the message names the leaf. -->
1044
1121
  <DiagnosticList diagnostics={routed.below.get(k)?.map((d) => d.diagnostic)} />
1045
- <ReviewRows entries={rowReview(k)} value={arr[k]} member />
1122
+ <ReviewRows entries={rowKept(k)} member />
1046
1123
  {/if}
1047
1124
  </div>
1048
1125
  {/each}
1126
+ {#each added as { item }, n (item.id)}{@render addedRow(item, arr.length + n)}{/each}
1049
1127
  </div>
1050
1128
  {:else}
1051
1129
  <div
1052
- class={['qm-array-rows qm-wash', { empty: rowIds.length === 0 }]}
1130
+ class={['qm-array-rows qm-wash', { empty: rowIds.length === 0 && !added.length }]}
1053
1131
  data-default={defaulted ? '' : undefined}
1054
1132
  bind:this={rowsEl}
1055
1133
  >
@@ -1058,6 +1136,7 @@
1058
1136
  <div
1059
1137
  class={['qm-array-row qm-wash', { standing: id === standingId }]}
1060
1138
  data-qm-index={k}
1139
+ {...removedRow(k)}
1061
1140
  bind:this={rowEls[id]}
1062
1141
  onkeydown={(e) => onRowKey(e, k)}
1063
1142
  >
@@ -1066,6 +1145,7 @@
1066
1145
  bind:this={els[id]}
1067
1146
  content={() => readAt([k])}
1068
1147
  value={arr[k]}
1148
+ proposed={rowText(k)}
1069
1149
  plaintext={items != null && literalText(items)}
1070
1150
  cap={textCap(items)}
1071
1151
  label={rowName(k)}
@@ -1080,7 +1160,8 @@
1080
1160
  />
1081
1161
  {:else if control === 'number'}
1082
1162
  <NumberField
1083
- value={arr[k] as number | undefined}
1163
+ value={rowShown(k) as number | undefined}
1164
+ proposed={rowNumber(k)}
1084
1165
  integer={items != null && baseType(items) === 'integer'}
1085
1166
  placeholder={id === standingId ? t.strings.arrayStanding : undefined}
1086
1167
  label={rowName(k)}
@@ -1090,30 +1171,31 @@
1090
1171
  {:else if control === 'enum'}
1091
1172
  <!-- The blank is an element's empty answer, drawn as an unanswered one. -->
1092
1173
  <EnumField
1093
- value={(arr[k] as string | undefined) || undefined}
1174
+ value={(rowShown(k) as string | undefined) || undefined}
1094
1175
  values={items?.values ?? []}
1095
1176
  blankTitle={items?.ui?.blank_title}
1096
1177
  label={rowName(k)}
1097
- onCommit={(v) => commitElement(k, v)}
1178
+ onCommit={(v) => commitRow(k, v)}
1179
+ proposing={!!rowOwn(k)}
1098
1180
  />
1099
1181
  {:else if control === 'boolean'}
1100
1182
  <BooleanField
1101
- value={renderedBoolean(arr[k])}
1183
+ value={renderedBoolean(rowShown(k))}
1102
1184
  label={rowName(k)}
1103
- onCommit={(v) => commitElement(k, v)}
1185
+ onCommit={(v) => commitRow(k, v)}
1104
1186
  />
1105
1187
  {:else if control === 'date'}
1106
1188
  <DateField
1107
1189
  bind:this={els[id]}
1108
- value={(arr[k] as string | undefined) || undefined}
1190
+ value={(rowShown(k) as string | undefined) || undefined}
1109
1191
  datetime={items != null && baseType(items) === 'datetime'}
1110
1192
  label={rowName(k)}
1111
- onCommit={(v) => commitElement(k, v)}
1193
+ onCommit={(v) => commitRow(k, v)}
1112
1194
  />
1113
1195
  {:else}
1114
1196
  <TextField
1115
1197
  bind:this={els[id]}
1116
- value={String(arr[k] ?? '')}
1198
+ value={String(rowShown(k) ?? '')}
1117
1199
  placeholder={id === standingId ? t.strings.arrayStanding : undefined}
1118
1200
  label={rowName(k)}
1119
1201
  onCommit={(v) => commitElement(k, v)}
@@ -1126,15 +1208,100 @@
1126
1208
  </div>
1127
1209
  {/if}
1128
1210
  <DiagnosticList diagnostics={routed.below.get(k)?.map((d) => d.diagnostic)} />
1129
- <ReviewRows entries={rowReview(k)} value={arr[k]} member />
1211
+ <ReviewRows entries={rowMarks(k)} member />
1130
1212
  </div>
1131
1213
  {/each}
1214
+ {#each added as { item }, n (item.id)}{@render addedRow(item, arr.length + n)}{/each}
1132
1215
  </div>
1133
1216
  {/if}
1134
1217
  <DiagnosticList diagnostics={foot} />
1135
- <ReviewRows entries={reviewFoot} value={arr} member />
1218
+ <ReviewRows entries={reviewFoot} member />
1136
1219
  </div>
1137
1220
 
1221
+ <!-- A member the review would add, drawn where it would stand as the row's own control holding
1222
+ the value, tinted and inert: a table's as a row of its cells under the same headers, a record
1223
+ list's collapsed to its summary. The row, not the control, hears the pointer and carries the
1224
+ item, so a press on it names the item and the answer card stands on it. -->
1225
+ {#snippet addedRow(item: FieldProposal, k: number)}
1226
+ {@const after = item.after}
1227
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
1228
+ <div
1229
+ class={[
1230
+ 'qm-array-row qm-review-added',
1231
+ {
1232
+ 'qm-array-table-row': table,
1233
+ 'qm-element': control === 'object' && !table,
1234
+ 'qm-review-lit': reviewing.lit === item.id
1235
+ }
1236
+ ]}
1237
+ data-qm-review={item.id}
1238
+ role="group"
1239
+ aria-label={t.strings.reviewNewItem}
1240
+ onpointerenter={() => reviewing.point(item.id, 'pointer')}
1241
+ onpointerleave={() => reviewing.point(undefined, 'pointer')}
1242
+ >
1243
+ <div class="qm-review-added-box" inert>
1244
+ {#if table}
1245
+ <ObjectField
1246
+ bare
1247
+ value={(after ?? {}) as Record<string, unknown>}
1248
+ properties={items?.properties}
1249
+ label={rowName(k)}
1250
+ contentAt={(path) => asContent(valueIn(after, path))}
1251
+ onCommit={() => {}}
1252
+ />
1253
+ {:else if control === 'object'}
1254
+ <div class="qm-element-head">
1255
+ <span class="qm-row-handle" aria-hidden="true"></span>
1256
+ <span class="qm-control-box qm-element-summary">
1257
+ <Icon name="chevron-right" class="qm-el-chevron" size={CHEVRON} />
1258
+ <span class="qm-element-title">{t.strings.elementItem(k + 1)}</span>
1259
+ {#if firstShortText(items?.properties, (after ?? {}) as Record<string, unknown>)}
1260
+ <span class="qm-element-preview"
1261
+ >{firstShortText(items?.properties, (after ?? {}) as Record<string, unknown>)}</span
1262
+ >
1263
+ {/if}
1264
+ </span>
1265
+ </div>
1266
+ {:else if control === 'prose'}
1267
+ <ProseValue
1268
+ content={() => asContent(after)}
1269
+ value={after}
1270
+ plaintext={items != null && literalText(items)}
1271
+ label={rowName(k)}
1272
+ onChange={() => {}}
1273
+ />
1274
+ {:else if control === 'number'}
1275
+ <NumberField
1276
+ value={after as number | undefined}
1277
+ integer={items != null && baseType(items) === 'integer'}
1278
+ label={rowName(k)}
1279
+ onCommit={() => {}}
1280
+ />
1281
+ {:else if control === 'enum'}
1282
+ <EnumField
1283
+ value={(after as string | undefined) || undefined}
1284
+ values={items?.values ?? []}
1285
+ blankTitle={items?.ui?.blank_title}
1286
+ label={rowName(k)}
1287
+ onCommit={() => {}}
1288
+ />
1289
+ {:else if control === 'boolean'}
1290
+ <BooleanField value={renderedBoolean(after)} label={rowName(k)} onCommit={() => {}} />
1291
+ {:else if control === 'date'}
1292
+ <DateField
1293
+ value={(after as string | undefined) || undefined}
1294
+ datetime={items != null && baseType(items) === 'datetime'}
1295
+ label={rowName(k)}
1296
+ onCommit={() => {}}
1297
+ />
1298
+ {:else}
1299
+ <TextField value={String(after ?? '')} label={rowName(k)} onCommit={() => {}} />
1300
+ {/if}
1301
+ </div>
1302
+ </div>
1303
+ {/snippet}
1304
+
1138
1305
  <!-- The remove, one button wherever a row ends: a scalar row's slab, a record row's
1139
1306
  slab after its reorder pair, a table row's last track. Out of the tab order where the
1140
1307
  row has a key that removes it: Backspace on an emptied line, ⌘/Ctrl+Backspace on a
@@ -1463,6 +1630,13 @@
1463
1630
  }
1464
1631
  /* What the closed record holds, after its name and a rung under it: the label ink,
1465
1632
  on the line's remainder, and the first to give way where the line runs short. */
1633
+ .qm-review-tag {
1634
+ flex: none;
1635
+ margin-inline-start: auto;
1636
+ font-size: var(--_qm-text-label);
1637
+ font-weight: var(--_qm-weight-mid);
1638
+ color: var(--_qm-ink-label);
1639
+ }
1466
1640
  .qm-element-preview {
1467
1641
  flex: 1 1 0;
1468
1642
  min-width: 0;
@@ -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();
@@ -246,6 +250,7 @@
246
250
  </span>
247
251
  </div>
248
252
  <div class="qm-card-header-right">
253
+ {#if tag}<span class="qm-card-tag">{tag}</span>{/if}
249
254
  <CardControls
250
255
  {isFirst}
251
256
  {isLast}
@@ -408,6 +413,7 @@
408
413
  <header class="qm-card-header">
409
414
  <span class="qm-card-title-static">{humanize(card.kind)}</span>
410
415
  <div class="qm-card-header-right">
416
+ {#if tag}<span class="qm-card-tag">{tag}</span>{/if}
411
417
  <CardControls
412
418
  {isFirst}
413
419
  {isLast}
@@ -494,6 +500,11 @@
494
500
  padding-inline: var(--_qm-column);
495
501
  margin-block: calc(-1 * var(--_qm-space-3) / 2);
496
502
  }
503
+ .qm-card-tag {
504
+ font-size: var(--_qm-text-label);
505
+ font-weight: var(--_qm-weight-mid);
506
+ color: var(--_qm-ink-label);
507
+ }
497
508
  .qm-card-header-right {
498
509
  display: flex;
499
510
  align-items: center;
@@ -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;
@@ -45,6 +45,9 @@
45
45
  optionAllowed?: (value: string) => boolean;
46
46
  /** How a refused option draws: greyed and unpickable, or left out of the list. */
47
47
  enumDisallowed?: 'hide' | 'disable';
48
+ /** `value` is a proposal's, not the document's: the list marks it, and every pick
49
+ * commits, the proposed member's included, so a pick answers the proposal. */
50
+ proposing?: boolean;
48
51
  }
49
52
  let {
50
53
  value,
@@ -57,13 +60,16 @@
57
60
  describedBy,
58
61
  onCommit,
59
62
  optionAllowed,
60
- enumDisallowed = 'disable'
63
+ enumDisallowed = 'disable',
64
+ proposing = false
61
65
  }: Props = $props();
62
66
 
63
67
  // The sentinel's option value: a namespaced marker that no schema-authored
64
68
  // enum member would ever be (`values` are classification markings, seal ids, and
65
69
  // the like), so it never collides with a real option.
66
70
  const UNSET = '__qm_unset__';
71
+ /** What the primitive holds while a proposal stands: no option, so every pick changes it. */
72
+ const PROPOSED = '__qm_proposed__';
67
73
 
68
74
  // Driven controlled (`value` + `onValueChange`, never `bind:`) so reconciliation
69
75
  // stays the package's rather than the primitive's.
@@ -99,9 +105,9 @@
99
105
  <Select.Root
100
106
  type="single"
101
107
  allowDeselect={false}
102
- value={local}
108
+ value={proposing ? PROPOSED : local}
103
109
  onValueChange={(v) => {
104
- if (v == null) return;
110
+ if (v == null || v === PROPOSED) return;
105
111
  local = v;
106
112
  // Sentinel → unset (parent `removeField`, default renders); any real pick
107
113
  // (incl. the default value) → a genuine write.
@@ -119,7 +125,11 @@
119
125
  <Icon name="chevron-down" class="qm-select-chevron" />
120
126
  </Select.Trigger>
121
127
  <Select.Portal to={portalTarget}>
122
- <Select.Content collisionBoundary={portalTarget ?? []} sideOffset={spacePx(wrapEl)}>
128
+ <Select.Content
129
+ collisionBoundary={portalTarget ?? []}
130
+ strategy="absolute"
131
+ sideOffset={spacePx(wrapEl)}
132
+ >
123
133
  <!-- The list portals out of the trigger's DOM but into the nearest
124
134
  `[data-qm-root]`, and carries the marker itself, like FormatPopover.
125
135
  That root is the boundary a flip is measured against too, being the box
@@ -24,6 +24,9 @@ interface Props {
24
24
  optionAllowed?: (value: string) => boolean;
25
25
  /** How a refused option draws: greyed and unpickable, or left out of the list. */
26
26
  enumDisallowed?: 'hide' | 'disable';
27
+ /** `value` is a proposal's, not the document's: the list marks it, and every pick
28
+ * commits, the proposed member's included, so a pick answers the proposal. */
29
+ proposing?: boolean;
27
30
  }
28
31
  declare const EnumField: import("svelte").Component<Props, {}, "">;
29
32
  type EnumField = ReturnType<typeof EnumField>;