@quillmark/svelte 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -1
- package/THEMING.md +11 -10
- package/dist/core/codec/anchor.d.ts +12 -0
- package/dist/core/codec/anchor.js +39 -0
- package/dist/core/codec/drag-move.d.ts +11 -0
- package/dist/core/codec/drag-move.js +143 -0
- package/dist/core/codec/encode.d.ts +2 -1
- package/dist/core/codec/encode.js +16 -6
- package/dist/core/codec/field.d.ts +47 -1
- package/dist/core/codec/field.js +201 -37
- package/dist/core/codec/index.d.ts +8 -2
- package/dist/core/codec/index.js +9 -2
- package/dist/core/codec/islands.d.ts +4 -1
- package/dist/core/codec/islands.js +6 -0
- package/dist/core/codec/keymap.d.ts +3 -0
- package/dist/core/codec/keymap.js +13 -12
- package/dist/core/codec/leave.d.ts +17 -0
- package/dist/core/codec/leave.js +78 -0
- package/dist/core/codec/prose.css +217 -0
- package/dist/core/codec/review-diff.d.ts +12 -0
- package/dist/core/codec/review-diff.js +131 -0
- package/dist/core/codec/review.d.ts +131 -0
- package/dist/core/codec/review.js +1077 -0
- package/dist/core/codec/shortcuts.d.ts +20 -4
- package/dist/core/codec/shortcuts.js +27 -7
- package/dist/core/codec/slash.d.ts +3 -0
- package/dist/core/codec/slash.js +2 -1
- package/dist/core/codec/table-view.js +163 -25
- package/dist/core/codec/undo.d.ts +6 -0
- package/dist/core/codec/undo.js +25 -2
- package/dist/core/dragfollow.d.ts +18 -0
- package/dist/core/dragfollow.js +63 -0
- package/dist/core/theme.css +36 -7
- package/dist/preview/controller.js +16 -0
- package/dist/preview/strings.d.ts +4 -0
- package/dist/preview/strings.js +3 -1
- package/dist/visual/ArrayField.svelte +363 -57
- package/dist/visual/ArrayField.svelte.d.ts +5 -0
- package/dist/visual/BooleanField.svelte +60 -5
- package/dist/visual/BooleanField.svelte.d.ts +2 -1
- package/dist/visual/Card.svelte +27 -17
- package/dist/visual/CardControls.svelte +17 -7
- package/dist/visual/CardControls.svelte.d.ts +2 -0
- package/dist/visual/DateField.svelte +90 -39
- package/dist/visual/DateField.svelte.d.ts +2 -2
- package/dist/visual/Field.svelte +126 -6
- package/dist/visual/FieldHint.svelte +24 -9
- package/dist/visual/FieldLabel.svelte +128 -22
- package/dist/visual/FieldLabel.svelte.d.ts +9 -0
- package/dist/visual/FormatPopover.svelte +125 -20
- package/dist/visual/MatrixAdd.svelte +13 -6
- package/dist/visual/MatrixAdd.svelte.d.ts +3 -2
- package/dist/visual/MatrixField.svelte +36 -8
- package/dist/visual/NumberField.svelte +27 -6
- package/dist/visual/NumberField.svelte.d.ts +3 -0
- package/dist/visual/ObjectField.svelte +25 -1
- package/dist/visual/ObjectField.svelte.d.ts +6 -0
- package/dist/visual/ProseField.svelte +23 -0
- package/dist/visual/ProseField.svelte.d.ts +3 -0
- package/dist/visual/ProseValue.svelte +107 -17
- package/dist/visual/ProseValue.svelte.d.ts +18 -4
- package/dist/visual/ReviewPopover.svelte +179 -0
- package/dist/visual/ReviewPopover.svelte.d.ts +16 -0
- package/dist/visual/ReviewProposal.svelte +149 -0
- package/dist/visual/ReviewProposal.svelte.d.ts +15 -0
- package/dist/visual/ReviewRows.svelte +68 -0
- package/dist/visual/ReviewRows.svelte.d.ts +11 -0
- package/dist/visual/SlashMenu.svelte +13 -1
- package/dist/visual/SlashMenu.svelte.d.ts +2 -0
- package/dist/visual/VisualEditor.svelte +23 -0
- package/dist/visual/VisualEditor.svelte.d.ts +7 -0
- package/dist/visual/VisualEditorInner.svelte +671 -22
- package/dist/visual/VisualEditorInner.svelte.d.ts +7 -0
- package/dist/visual/controls.css +17 -2
- package/dist/visual/guidance.d.ts +12 -0
- package/dist/visual/guidance.js +37 -2
- package/dist/visual/icons/nodes.d.ts +14 -2
- package/dist/visual/icons/nodes.js +12 -1
- package/dist/visual/index.d.ts +6 -0
- package/dist/visual/index.js +2 -0
- package/dist/visual/listhistory.d.ts +36 -0
- package/dist/visual/listhistory.js +53 -0
- package/dist/visual/proposals.d.ts +40 -0
- package/dist/visual/proposals.js +219 -0
- package/dist/visual/props.d.ts +35 -0
- package/dist/visual/removed.d.ts +20 -0
- package/dist/visual/removed.js +30 -0
- package/dist/visual/review.d.ts +170 -0
- package/dist/visual/review.js +269 -0
- package/dist/visual/review.svelte.d.ts +106 -0
- package/dist/visual/review.svelte.js +356 -0
- package/dist/visual/rowdrag.svelte.js +44 -55
- package/dist/visual/strings.d.ts +48 -7
- package/dist/visual/strings.js +32 -7
- package/dist/visual/structure.d.ts +5 -0
- package/dist/visual/structure.js +1 -1
- package/dist/visual/undo.svelte.d.ts +40 -7
- package/dist/visual/undo.svelte.js +98 -25
- package/package.json +1 -1
package/dist/visual/Field.svelte
CHANGED
|
@@ -57,6 +57,11 @@
|
|
|
57
57
|
import MatrixField from './MatrixField.svelte';
|
|
58
58
|
import DiagnosticList from './DiagnosticList.svelte';
|
|
59
59
|
import FieldLabel from './FieldLabel.svelte';
|
|
60
|
+
import ReviewProposal from './ReviewProposal.svelte';
|
|
61
|
+
import ReviewRows from './ReviewRows.svelte';
|
|
62
|
+
import { review } from './review.svelte.js';
|
|
63
|
+
import { REVIEW_KEYS } from '../core/codec/index.js';
|
|
64
|
+
import { keydownHandler } from 'prosemirror-keymap';
|
|
60
65
|
|
|
61
66
|
interface Props {
|
|
62
67
|
field: FieldModel;
|
|
@@ -142,6 +147,26 @@
|
|
|
142
147
|
// resolves to digits, and the control has to know it follows the render date.
|
|
143
148
|
const declared = $derived(printedText(field.schema.default));
|
|
144
149
|
const optional = $derived(optionalCell(field.schema));
|
|
150
|
+
// Where the field stands against its default, for the label row's end (`FieldLabel`):
|
|
151
|
+
// unset with the default printing, or written over one that would. A container's
|
|
152
|
+
// source is its cells' composed, so only a control holding one value says either.
|
|
153
|
+
const scalar = $derived(!isContainer(field.control));
|
|
154
|
+
// A prose leaf commits past the derive (`VisualEditorInner` `proseChanged`), so its
|
|
155
|
+
// row stands as the last derive left it. The leaf's commit says whether the field is
|
|
156
|
+
// written since, and holds until the next derive hands a row that answers.
|
|
157
|
+
let since = $state.raw<{ row: ResolvedField | undefined; written: boolean }>();
|
|
158
|
+
const written = $derived(
|
|
159
|
+
since && since.row === provenance ? since.written : provenance?.source === 'authored'
|
|
160
|
+
);
|
|
161
|
+
const defaulted = $derived(
|
|
162
|
+
scalar && !written && provenance?.source === 'default' && printed !== undefined
|
|
163
|
+
);
|
|
164
|
+
const resettable = $derived(scalar && written && declared !== undefined);
|
|
165
|
+
const defaultId = $derived(`${domIds.control}-default`);
|
|
166
|
+
function proseCommitted(at: Addr): void {
|
|
167
|
+
since = { row: provenance, written: doc.getStored(at) != null };
|
|
168
|
+
onChange?.(at);
|
|
169
|
+
}
|
|
145
170
|
const none = $derived(optional && value == null ? t.strings.optionalGhost : undefined);
|
|
146
171
|
// A variant resolves as one rung whose value is the whole container, so the
|
|
147
172
|
// discriminant's ghost is that container's own discriminant cell.
|
|
@@ -165,14 +190,19 @@
|
|
|
165
190
|
// The parked description node renders only when the schema carries one, so the
|
|
166
191
|
// reference must vanish with it: `aria-describedby` pointing at nothing describes
|
|
167
192
|
// nothing, and silently.
|
|
168
|
-
const
|
|
193
|
+
const description = $derived(field.description ? domIds.description : undefined);
|
|
194
|
+
// The default tag describes the control while it stands. A prose leaf takes the tag's
|
|
195
|
+
// id apart and adds it itself, on the mark it keeps of its own default (`createField`).
|
|
196
|
+
const describedBy = $derived(
|
|
197
|
+
defaulted ? [description, defaultId].filter(Boolean).join(' ') : description
|
|
198
|
+
);
|
|
169
199
|
// A capped prose leaf reports its count, and the count describes it too: a keystroke
|
|
170
200
|
// the cap refuses changes nothing else a reader can perceive.
|
|
171
201
|
let chars = $state<number>();
|
|
172
202
|
const cap = $derived(field.control === 'prose' ? textCap(field.schema) : undefined);
|
|
173
203
|
const countId = $derived(`${domIds.control}-count`);
|
|
174
204
|
const proseDescribedBy = $derived(
|
|
175
|
-
cap ? [
|
|
205
|
+
cap ? [description, countId].filter(Boolean).join(' ') : description
|
|
176
206
|
);
|
|
177
207
|
// Two controls own their label row, the add chip and the held count sharing it.
|
|
178
208
|
const ownsLabel = $derived(field.control === 'array' || field.control === 'matrix');
|
|
@@ -232,6 +262,13 @@
|
|
|
232
262
|
// Only where `for` cannot reach; the labelable four are the browser's own, and a
|
|
233
263
|
// second handler over them would be a focus the label already placed.
|
|
234
264
|
const onActivate = $derived(labelable ? undefined : focusControl);
|
|
265
|
+
/** Back to the default: the field unset, and the focus on its control, the button
|
|
266
|
+
* that held it leaving with the written value. */
|
|
267
|
+
function reset(): void {
|
|
268
|
+
since = undefined;
|
|
269
|
+
onCommitScalar(undefined);
|
|
270
|
+
focusControl();
|
|
271
|
+
}
|
|
235
272
|
|
|
236
273
|
/**
|
|
237
274
|
* This field's landing handle. The wrapper is the bloom host rather than the
|
|
@@ -280,6 +317,42 @@
|
|
|
280
317
|
* controller — the source that drives its caret signals too — and is excluded here
|
|
281
318
|
* rather than counted twice.
|
|
282
319
|
*/
|
|
320
|
+
// ── Review: this field's own items (`review.svelte.ts`) ──────────────────────
|
|
321
|
+
// A change rests as a line on the control's edge and a proposal as a row under it. The
|
|
322
|
+
// pointer over the control and the focus in it are the field's two ways of being attended
|
|
323
|
+
// to, as the pointer and the caret are a mark's.
|
|
324
|
+
const reviewing = review();
|
|
325
|
+
const reviewed = $derived(reviewing.at(leafKey));
|
|
326
|
+
const changed = $derived(reviewed.changed);
|
|
327
|
+
const proposed = $derived(reviewed.proposed);
|
|
328
|
+
/** The items naming a place inside this field: a record's and a list's own controls draw
|
|
329
|
+
* them where they are, any other's under this one. */
|
|
330
|
+
const nestedReview = $derived(reviewed.nested);
|
|
331
|
+
const lit = $derived(changed !== undefined && reviewing.lit === changed.id);
|
|
332
|
+
/** The item the focus in the field attends to: the change, whose card it raises, else the
|
|
333
|
+
* proposal. */
|
|
334
|
+
const attended = $derived(changed ?? proposed);
|
|
335
|
+
/** The chords, with the focus anywhere in the field: a proposal's answers, else an accepted
|
|
336
|
+
* one taken back. A prose leaf's own items answer first, in the leaf. */
|
|
337
|
+
const reviewKeys = keydownHandler({
|
|
338
|
+
[REVIEW_KEYS.accept]: () => {
|
|
339
|
+
if (!proposed) return false;
|
|
340
|
+
reviewing.act(proposed.id, 'accept', true);
|
|
341
|
+
return true;
|
|
342
|
+
},
|
|
343
|
+
[REVIEW_KEYS.dismiss]: () => {
|
|
344
|
+
const item = proposed ?? changed;
|
|
345
|
+
if (!item) return false;
|
|
346
|
+
reviewing.act(item.id, proposed ? 'dismiss' : 'reopen', true);
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
function onReviewKey(e: KeyboardEvent): void {
|
|
351
|
+
if (e.defaultPrevented || (!changed && !proposed)) return;
|
|
352
|
+
// The bindings read no view: this is `prosemirror-keymap`'s chord matcher alone.
|
|
353
|
+
if (reviewKeys({} as never, e)) e.preventDefault();
|
|
354
|
+
}
|
|
355
|
+
|
|
283
356
|
const reportFocus = $derived(
|
|
284
357
|
field.control === 'prose'
|
|
285
358
|
? undefined
|
|
@@ -288,7 +361,9 @@
|
|
|
288
361
|
);
|
|
289
362
|
</script>
|
|
290
363
|
|
|
291
|
-
|
|
364
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
365
|
+
<!-- The keydown is a control's, bubbled: the field answers the review chords for it. -->
|
|
366
|
+
<div class={['qm-field', { cell: span === 'cell' }]} data-tail={tail} onkeydown={onReviewKey}>
|
|
292
367
|
{#if !ownsLabel && !headed}
|
|
293
368
|
<FieldLabel
|
|
294
369
|
label={field.label}
|
|
@@ -299,6 +374,9 @@
|
|
|
299
374
|
description={field.description}
|
|
300
375
|
count={cap && chars != null ? t.strings.textCount(chars, cap.max) : undefined}
|
|
301
376
|
{countId}
|
|
377
|
+
{defaulted}
|
|
378
|
+
{defaultId}
|
|
379
|
+
onReset={resettable ? reset : undefined}
|
|
302
380
|
/>
|
|
303
381
|
{/if}
|
|
304
382
|
<!-- The control and what hangs under it, in one grid cell: the diagnostics stack
|
|
@@ -306,7 +384,19 @@
|
|
|
306
384
|
rule below holds why). One markup for both spans; a field owning its row nests a
|
|
307
385
|
level and measures the same. -->
|
|
308
386
|
<div class="qm-field-stack">
|
|
309
|
-
<div
|
|
387
|
+
<div
|
|
388
|
+
class={['qm-field-control qm-wash', { 'qm-review-set': changed, 'qm-review-lit': lit }]}
|
|
389
|
+
data-qm-review={changed?.id}
|
|
390
|
+
{@attach registerControl}
|
|
391
|
+
onfocusin={(e) => {
|
|
392
|
+
reportFocus?.(e);
|
|
393
|
+
if (attended) reviewing.point(attended.id, 'caret', leafKey);
|
|
394
|
+
}}
|
|
395
|
+
onfocusout={() => attended && reviewing.point(undefined, 'caret', leafKey)}
|
|
396
|
+
oninput={() => changed && reviewing.point(undefined, 'caret')}
|
|
397
|
+
onpointerenter={() => changed && reviewing.point(changed.id, 'pointer')}
|
|
398
|
+
onpointerleave={() => changed && reviewing.point(undefined, 'pointer')}
|
|
399
|
+
>
|
|
310
400
|
{#if field.control === 'prose'}
|
|
311
401
|
<ProseField
|
|
312
402
|
{quill}
|
|
@@ -320,11 +410,12 @@
|
|
|
320
410
|
emptyUnsets={optional}
|
|
321
411
|
labelledBy={domIds.label}
|
|
322
412
|
describedBy={proseDescribedBy}
|
|
413
|
+
defaultNoteId={defaultId}
|
|
323
414
|
cap={cap && { ...cap, onCount: (n) => (chars = n) }}
|
|
324
415
|
{leafKey}
|
|
325
416
|
{onFocus}
|
|
326
417
|
{onCaretMove}
|
|
327
|
-
{
|
|
418
|
+
onChange={proseCommitted}
|
|
328
419
|
{onError}
|
|
329
420
|
{leaves}
|
|
330
421
|
{diagnostics}
|
|
@@ -403,6 +494,7 @@
|
|
|
403
494
|
{contentAt}
|
|
404
495
|
onCommit={onCommitScalar}
|
|
405
496
|
diagnostics={deep}
|
|
497
|
+
review={nestedReview}
|
|
406
498
|
/>
|
|
407
499
|
{:else if field.control === 'object'}
|
|
408
500
|
<ObjectField
|
|
@@ -418,6 +510,7 @@
|
|
|
418
510
|
{contentAt}
|
|
419
511
|
onCommit={onCommitScalar}
|
|
420
512
|
diagnostics={deep}
|
|
513
|
+
review={nestedReview}
|
|
421
514
|
/>
|
|
422
515
|
{:else if field.control === 'matrix'}
|
|
423
516
|
<MatrixField
|
|
@@ -445,7 +538,13 @@
|
|
|
445
538
|
{/if}
|
|
446
539
|
</div>
|
|
447
540
|
|
|
448
|
-
{#if
|
|
541
|
+
{#if field.control !== 'object' && field.control !== 'array'}
|
|
542
|
+
<ReviewRows entries={nestedReview} {value} />
|
|
543
|
+
{/if}
|
|
544
|
+
{#if proposed}
|
|
545
|
+
<ReviewProposal item={proposed} {value} refocus={focusControl} />
|
|
546
|
+
{/if}
|
|
547
|
+
{#if scalar}
|
|
449
548
|
<DiagnosticList {diagnostics} />
|
|
450
549
|
{/if}
|
|
451
550
|
</div>
|
|
@@ -465,6 +564,10 @@
|
|
|
465
564
|
grid-column: 1 / -1;
|
|
466
565
|
min-width: 0;
|
|
467
566
|
}
|
|
567
|
+
/* The way back to the default arrives with the field's hover or focus (`FieldLabel`). */
|
|
568
|
+
.qm-field:is(:hover, :focus-within) > :global(.qm-field-label-row > .qm-field-reset) {
|
|
569
|
+
opacity: 1;
|
|
570
|
+
}
|
|
468
571
|
/* A row-sharing field subgrids onto the section's row tracks instead of sizing its
|
|
469
572
|
own: two tracks, the label and the control's stack, taken from the parent, so
|
|
470
573
|
every control in a visual row starts at the same y however tall a neighbour's
|
|
@@ -511,4 +614,21 @@
|
|
|
511
614
|
.qm-field-control {
|
|
512
615
|
border-radius: var(--_qm-radius-inner);
|
|
513
616
|
}
|
|
617
|
+
/* A value someone else set is underlined as a changed word is: the same stroke along the
|
|
618
|
+
control's foot, and under attention the tint a lit word takes. A plane over the
|
|
619
|
+
control, as the wash is, so it reads the same over a well, a switch and a subform, and
|
|
620
|
+
lifted over the control's own positioned box. */
|
|
621
|
+
.qm-field-control.qm-review-set::before {
|
|
622
|
+
content: '';
|
|
623
|
+
position: absolute;
|
|
624
|
+
inset: 0;
|
|
625
|
+
border-radius: inherit;
|
|
626
|
+
box-shadow: inset 0 calc(-1 * var(--_qm-vertical-width)) 0 var(--_qm-review-line);
|
|
627
|
+
z-index: 1;
|
|
628
|
+
pointer-events: none;
|
|
629
|
+
transition: background-color var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
630
|
+
}
|
|
631
|
+
.qm-field-control.qm-review-set.qm-review-lit::before {
|
|
632
|
+
background: var(--_qm-review-tint);
|
|
633
|
+
}
|
|
514
634
|
</style>
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
on touch, which leaves guidance the reference quill puts on nearly every field
|
|
10
10
|
reachable on a tablet only through a screen reader.
|
|
11
11
|
|
|
12
|
-
Floating
|
|
13
|
-
to a median of ~110 characters and past 250 at the tail
|
|
14
|
-
is several wrapped lines under every field, which is the
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
Floating, for a description past a line or so (`isBrief`): the reference quill's
|
|
13
|
+
descriptions run to a median of ~110 characters and past 250 at the tail, and
|
|
14
|
+
permanently in flow that is several wrapped lines under every field, which is the
|
|
15
|
+
density the card is built to avoid. A short one stands under its label instead
|
|
16
|
+
({@link FieldLabel}) and raises no marker.
|
|
17
17
|
|
|
18
18
|
The popover is chrome, not the announcement. Its content is `aria-hidden`: the
|
|
19
19
|
description reaches assistive tech through the always-present parked node
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
import { Popover } from 'bits-ui';
|
|
33
33
|
import Icon from './icons/Icon.svelte';
|
|
34
34
|
import { spacePx } from '../core/rungs.js';
|
|
35
|
+
import { renderGuidance } from './guidance.js';
|
|
35
36
|
import './controls.css';
|
|
36
37
|
|
|
37
38
|
interface Props {
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
probe.className = 'qm-hint-popover';
|
|
78
79
|
probe.style.cssText =
|
|
79
80
|
'position:absolute;width:max-content;visibility:hidden;pointer-events:none';
|
|
80
|
-
probe.
|
|
81
|
+
probe.replaceChildren(renderGuidance(description));
|
|
81
82
|
host.appendChild(probe);
|
|
82
83
|
const range = document.createRange();
|
|
83
84
|
range.selectNodeContents(probe);
|
|
@@ -106,6 +107,11 @@
|
|
|
106
107
|
* the trigger never does, so its leaving and its Escape are what lower the surface. */
|
|
107
108
|
let from = $state<HTMLElement | undefined>(undefined);
|
|
108
109
|
|
|
110
|
+
/** The description is DOM, not text (`renderGuidance`), so it is written in. */
|
|
111
|
+
function paint(surface: HTMLElement): void {
|
|
112
|
+
surface.replaceChildren(renderGuidance(description));
|
|
113
|
+
}
|
|
114
|
+
|
|
109
115
|
function raise(origin?: HTMLElement): void {
|
|
110
116
|
from = origin;
|
|
111
117
|
beside = ridesTheRung();
|
|
@@ -228,9 +234,8 @@
|
|
|
228
234
|
data-qm-root
|
|
229
235
|
aria-hidden="true"
|
|
230
236
|
inert={!raised}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
</div>
|
|
237
|
+
{@attach paint}
|
|
238
|
+
></div>
|
|
234
239
|
</div>
|
|
235
240
|
{/snippet}
|
|
236
241
|
</Popover.Content>
|
|
@@ -304,4 +309,14 @@
|
|
|
304
309
|
line-height: var(--_qm-leading-body);
|
|
305
310
|
color: var(--_qm-ink-label);
|
|
306
311
|
}
|
|
312
|
+
/* The rendered description is the codec's `toDOM` output, one paragraph. `code` takes
|
|
313
|
+
the face a leaf gives it (`core/codec/prose.css`) and no chip, the surface being
|
|
314
|
+
translucent already. */
|
|
315
|
+
:global(.qm-hint-popover p) {
|
|
316
|
+
margin: 0;
|
|
317
|
+
}
|
|
318
|
+
:global(.qm-hint-popover code) {
|
|
319
|
+
font-family: var(--_qm-font-mono);
|
|
320
|
+
font-size: inherit;
|
|
321
|
+
}
|
|
307
322
|
</style>
|
|
@@ -10,11 +10,18 @@
|
|
|
10
10
|
hands the click to `onActivate`. Both halves are needed: `for` on a non-labelable
|
|
11
11
|
element is inert and invalid.
|
|
12
12
|
|
|
13
|
-
One non-gating label decoration: the `description
|
|
14
|
-
|
|
13
|
+
One non-gating label decoration: the `description`. A short one (`isBrief`) stands in
|
|
14
|
+
flow under the label, the row's second line, and is itself the node that describes the
|
|
15
|
+
control. A longer one is an info marker raising a themed popover ({@link FieldHint}).
|
|
15
16
|
|
|
16
|
-
The
|
|
17
|
-
|
|
17
|
+
The row's end says where the field stands against its `default:` (INVARIANTS §"The
|
|
18
|
+
commitment ladder"). While the default is what prints, a tag says so in words, and the
|
|
19
|
+
control is described by it. Once the field is written over a default, the same place
|
|
20
|
+
holds the way back: one button for every control, arriving with the field's hover or
|
|
21
|
+
focus as the guidance marker does, and named for its field.
|
|
22
|
+
|
|
23
|
+
The description describes, it does not name. Behind a marker it is parked in an
|
|
24
|
+
always-present visually-hidden node here and the control carries `aria-describedby`: name then
|
|
18
25
|
role then description, which is the announcement the markup visually implies. In
|
|
19
26
|
the name it would instead prepend ~110 characters of guidance (the reference
|
|
20
27
|
quill's median) to every field's label on every focus. Parked rather than read off
|
|
@@ -26,6 +33,11 @@
|
|
|
26
33
|
-->
|
|
27
34
|
<script lang="ts">
|
|
28
35
|
import FieldHint from './FieldHint.svelte';
|
|
36
|
+
import { guidanceText, isBrief, renderGuidance } from './guidance.js';
|
|
37
|
+
import { wording } from './strings.js';
|
|
38
|
+
import './controls.css';
|
|
39
|
+
|
|
40
|
+
const t = wording();
|
|
29
41
|
|
|
30
42
|
interface Props {
|
|
31
43
|
label: string;
|
|
@@ -40,16 +52,44 @@
|
|
|
40
52
|
onActivate?: () => void;
|
|
41
53
|
/** Schema `description`, or undefined: the affordance renders only when set. */
|
|
42
54
|
description?: string;
|
|
55
|
+
/** A short description stands under the label ({@link isBrief}). Off where the
|
|
56
|
+
* row has no second line to give, a table column's head. */
|
|
57
|
+
brief?: boolean;
|
|
43
58
|
/** A capped field's character count, drawn at the row's end. */
|
|
44
59
|
count?: string;
|
|
45
60
|
/** The count's own id, for the control's `aria-describedby`. */
|
|
46
61
|
countId?: string;
|
|
62
|
+
/** The field is unset and its `default:` is what prints. */
|
|
63
|
+
defaulted?: boolean;
|
|
64
|
+
/** The default tag's own id, for the control's `aria-describedby`. */
|
|
65
|
+
defaultId?: string;
|
|
66
|
+
/** Unset the field, where it is written over a `default:` that prints. */
|
|
67
|
+
onReset?: () => void;
|
|
68
|
+
}
|
|
69
|
+
let {
|
|
70
|
+
label,
|
|
71
|
+
controlId,
|
|
72
|
+
id,
|
|
73
|
+
descriptionId,
|
|
74
|
+
onActivate,
|
|
75
|
+
description,
|
|
76
|
+
brief = true,
|
|
77
|
+
count,
|
|
78
|
+
countId,
|
|
79
|
+
defaulted = false,
|
|
80
|
+
defaultId,
|
|
81
|
+
onReset
|
|
82
|
+
}: Props = $props();
|
|
83
|
+
|
|
84
|
+
const resetId = $props.id();
|
|
85
|
+
const inFlow = $derived(brief && description != null && isBrief(description));
|
|
86
|
+
/** The description is DOM, not text (`renderGuidance`), so it is written in. */
|
|
87
|
+
function paint(line: HTMLElement): void {
|
|
88
|
+
line.replaceChildren(renderGuidance(description ?? ''));
|
|
47
89
|
}
|
|
48
|
-
let { label, controlId, id, descriptionId, onActivate, description, count, countId }: Props =
|
|
49
|
-
$props();
|
|
50
90
|
</script>
|
|
51
91
|
|
|
52
|
-
<div class=
|
|
92
|
+
<div class={['qm-field-label-row', { briefed: inFlow }]}>
|
|
53
93
|
<!-- svelte-ignore a11y_no_noninteractive_element_interactions, a11y_click_events_have_key_events -->
|
|
54
94
|
<!-- The handler stands in for exactly what `for` would have done, on the controls
|
|
55
95
|
where `for` is inert. It adds no keyboard surface because it needs none: a
|
|
@@ -63,7 +103,10 @@
|
|
|
63
103
|
>
|
|
64
104
|
<span>{label}</span>
|
|
65
105
|
</label>
|
|
66
|
-
{#if
|
|
106
|
+
{#if inFlow}
|
|
107
|
+
<!-- The node that describes the control is the line a reader sees. -->
|
|
108
|
+
<div class="qm-field-brief" id={descriptionId} {@attach paint}></div>
|
|
109
|
+
{:else if description}
|
|
67
110
|
<!-- Outside the `<label>`, both of them: a trigger inside it would put its own
|
|
68
111
|
name in the control's, and the parked copy would put all ~110 characters
|
|
69
112
|
there. A `<button>` in a label is at least safe from the other hazard:
|
|
@@ -71,7 +114,19 @@
|
|
|
71
114
|
targeted at interactive content inside it; but the naming is reason
|
|
72
115
|
enough to keep both out. -->
|
|
73
116
|
<FieldHint {description} {label} describedBy={descriptionId} />
|
|
74
|
-
<span class="qm-visually-hidden" id={descriptionId}>{description}</span>
|
|
117
|
+
<span class="qm-visually-hidden" id={descriptionId}>{guidanceText(description)}</span>
|
|
118
|
+
{/if}
|
|
119
|
+
{#if defaulted}
|
|
120
|
+
<span class="qm-field-default" id={defaultId}>{t.strings.fieldDefault}</span>
|
|
121
|
+
{:else if onReset}
|
|
122
|
+
<!-- Named by its own word and then the field's: `Reset Font size`. -->
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
class="qm-field-reset qm-tap-floor qm-focus-ring"
|
|
126
|
+
id={resetId}
|
|
127
|
+
aria-labelledby={id ? `${resetId} ${id}` : undefined}
|
|
128
|
+
onclick={onReset}>{t.strings.fieldReset}</button
|
|
129
|
+
>
|
|
75
130
|
{/if}
|
|
76
131
|
{#if count != null}
|
|
77
132
|
<span class="qm-field-count" id={countId}>{count}</span>
|
|
@@ -99,28 +154,79 @@
|
|
|
99
154
|
color: var(--_qm-ink-label);
|
|
100
155
|
min-width: 0;
|
|
101
156
|
}
|
|
157
|
+
/* A short description, in flow: the row's own second line, so the field's grid still
|
|
158
|
+
counts one label track and a row-sharing neighbour's control starts level. Last
|
|
159
|
+
whatever stands at the first line's end. One weight under the label, which names
|
|
160
|
+
where this only describes. */
|
|
161
|
+
.qm-field-label-row.briefed {
|
|
162
|
+
flex-wrap: wrap;
|
|
163
|
+
row-gap: 0;
|
|
164
|
+
}
|
|
165
|
+
.qm-field-brief {
|
|
166
|
+
order: 1;
|
|
167
|
+
flex: 0 0 100%;
|
|
168
|
+
min-width: 0;
|
|
169
|
+
font-size: var(--_qm-text-label);
|
|
170
|
+
line-height: var(--_qm-leading-body);
|
|
171
|
+
color: var(--_qm-ink-label);
|
|
172
|
+
}
|
|
173
|
+
.qm-field-brief :global(p) {
|
|
174
|
+
margin: 0;
|
|
175
|
+
}
|
|
176
|
+
.qm-field-brief :global(code) {
|
|
177
|
+
font-family: var(--_qm-font-mono);
|
|
178
|
+
font-size: inherit;
|
|
179
|
+
}
|
|
102
180
|
.qm-field-count {
|
|
103
181
|
margin-inline-start: auto;
|
|
104
182
|
font-size: var(--_qm-text-label);
|
|
105
183
|
color: var(--_qm-ink-label);
|
|
106
184
|
font-variant-numeric: tabular-nums;
|
|
107
185
|
}
|
|
186
|
+
/* The row's end, the count's side, and ahead of a count where both stand. Words at the
|
|
187
|
+
label rung and a step under the label's weight, which names the field where this
|
|
188
|
+
only qualifies it. */
|
|
189
|
+
.qm-field-default,
|
|
190
|
+
.qm-field-reset {
|
|
191
|
+
flex: none;
|
|
192
|
+
margin-inline-start: auto;
|
|
193
|
+
font-size: var(--_qm-text-label);
|
|
194
|
+
line-height: var(--_qm-leading-tight);
|
|
195
|
+
color: var(--_qm-ink-label);
|
|
196
|
+
}
|
|
197
|
+
:is(.qm-field-default, .qm-field-reset) + .qm-field-count {
|
|
198
|
+
margin-inline-start: 0;
|
|
199
|
+
}
|
|
200
|
+
/* Unboxed, as a link in a line is: the row is a line of text, and a chip's floor
|
|
201
|
+
would stand taller than it (`.qm-tap-floor` carries the target). At rest it is
|
|
202
|
+
absent, as the guidance marker is and for its reason: a card written over its
|
|
203
|
+
defaults would otherwise stand the word beside every label. The field that owns
|
|
204
|
+
the row brings it up (`Field.svelte`). */
|
|
205
|
+
.qm-field-reset {
|
|
206
|
+
padding: 0;
|
|
207
|
+
border: 0;
|
|
208
|
+
border-radius: var(--_qm-radius-inner);
|
|
209
|
+
background: none;
|
|
210
|
+
font-family: inherit;
|
|
211
|
+
cursor: pointer;
|
|
212
|
+
opacity: 0;
|
|
213
|
+
transition: opacity var(--_qm-duration-fast) var(--_qm-ease-reverse);
|
|
214
|
+
}
|
|
215
|
+
.qm-field-reset:focus-visible {
|
|
216
|
+
opacity: 1;
|
|
217
|
+
}
|
|
218
|
+
.qm-field-reset:hover {
|
|
219
|
+
color: var(--_qm-ink);
|
|
220
|
+
text-decoration: underline;
|
|
221
|
+
}
|
|
222
|
+
@media (hover: none) {
|
|
223
|
+
.qm-field-reset {
|
|
224
|
+
opacity: 1;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
108
227
|
/* A label that lands focus says so. Only when it has somewhere to land: an
|
|
109
228
|
`ObjectField` property's label names a subform, not one control. */
|
|
110
229
|
.qm-field-label.targeted {
|
|
111
230
|
cursor: pointer;
|
|
112
231
|
}
|
|
113
|
-
/* The parked description: in the accessibility tree, out of the layout, and never
|
|
114
|
-
a focus stop. Clipped rather than `display: none` / `hidden`, which take a node
|
|
115
|
-
out of the tree entirely and would make the `aria-describedby` dangle. Out of
|
|
116
|
-
flow, so the classic recipe's `margin: -1px` has nothing left to counteract:
|
|
117
|
-
and it would mint a literal off every rung. */
|
|
118
|
-
.qm-visually-hidden {
|
|
119
|
-
position: absolute;
|
|
120
|
-
width: 1px;
|
|
121
|
-
height: 1px;
|
|
122
|
-
overflow: hidden;
|
|
123
|
-
clip-path: inset(50%);
|
|
124
|
-
white-space: nowrap;
|
|
125
|
-
}
|
|
126
232
|
</style>
|
|
@@ -11,10 +11,19 @@ interface Props {
|
|
|
11
11
|
onActivate?: () => void;
|
|
12
12
|
/** Schema `description`, or undefined: the affordance renders only when set. */
|
|
13
13
|
description?: string;
|
|
14
|
+
/** A short description stands under the label ({@link isBrief}). Off where the
|
|
15
|
+
* row has no second line to give, a table column's head. */
|
|
16
|
+
brief?: boolean;
|
|
14
17
|
/** A capped field's character count, drawn at the row's end. */
|
|
15
18
|
count?: string;
|
|
16
19
|
/** The count's own id, for the control's `aria-describedby`. */
|
|
17
20
|
countId?: string;
|
|
21
|
+
/** The field is unset and its `default:` is what prints. */
|
|
22
|
+
defaulted?: boolean;
|
|
23
|
+
/** The default tag's own id, for the control's `aria-describedby`. */
|
|
24
|
+
defaultId?: string;
|
|
25
|
+
/** Unset the field, where it is written over a `default:` that prints. */
|
|
26
|
+
onReset?: () => void;
|
|
18
27
|
}
|
|
19
28
|
declare const FieldLabel: import("svelte").Component<Props, {}, "">;
|
|
20
29
|
type FieldLabel = ReturnType<typeof FieldLabel>;
|